Pointer to class member as a template parameter

后端 未结 4 701
小蘑菇
小蘑菇 2020-12-09 09:27

I want to use a pointer to a class member as a template parameter as in:

template 
struct MyStruct {
         


        
4条回答
  •  Happy的楠姐
    2020-12-09 09:37

    An answer to my question was proposed in this paper for the next upcoming C++ standard:

    • https://isocpp.org/files/papers/n3601.html

    This syntax was proposed:

    template
    struct some_struct { /* ... */ };
    
    some_struct<&A::f> x;
    

    The need for a new syntactical construct indicates that you cannot do that by now.

    I hope n3601 will be accepted. :-)

提交回复
热议问题