c++ - decltype as a return type in class member function -


i got error compiling below code.

struct b{     double operator()(){         return 1.0;     } };  struct {     auto func() -> decltype(b())     {         return b();     }      b b; }; 

however, if reorganize a, compiles.

gcc 4.8 said 'b' not declared in scope.

struct {     b b;     auto func() -> decltype(b())     {         return b();     } }; 

so, wrong first??

the definition of class processed 2 passes: first member declarations collected, including function signatures, , bodies of definitions parsed.

the function body therefore has access member declarations, including subsequent ones, function prototype sees preceding declarations.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -