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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -