Auto incremented integer as a template parameter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pastbin@gmail.com

    Auto incremented integer as a template parameter

    Dear members,

    I would like to know if it exists a technique that would make the
    following code possible:

    //----
    template<int ID>
    struct ident
    {
    //...
    };

    void create_ident()
    {
    // the function body would contain that kind of expression:

    /*...*/new ident<AUTO_INCR EMENT_COUNTER>( );

    // where AUTO_INCREMENT_ COUNTER is controlled/generated
    // by the compiler
    }

    int main()
    {
    create_ident(); // would create ident<0>()
    create_ident(); // ident<1>()
    //..
    }
    //----

    I can't think of a solution for this problem. Of course I could make
    function create_ident() templated and simply call create_ident<N> ()
    but this is not what i want.
    What do you think of such a behavior ?

    Thank you,

    mark
Working...