c++ - Non-member variable detection -


I am trying to use SFINAE to find non-member variable existence. Actually it fixes my needs to check whether name was declared and can be seen in the actual scope, or not, by ignoring the type of variable.

Something like this:

  int var1; {Int var2; } Cout & lt; & Lt; Var1Exists :: Value & lt; & Lt; Endl; // True COAT & lt; & Lt; Var2Exists :: Value & lt; & Lt; Endl; // Wrong, because 'var2' exited the scope  

I've found how (actually found), but I have not managed to do it with a simple variable can do.

I am currently doing something like this:

  Namespace sfinae {template> Typename type & gt; Class variation {template & lt; Void * ptr & gt; Lowest structure; Template & lt; Typename T, typename ptr = lowest & lt; & Amp; Var1 & gt; * & Gt; Check the structure; Template & lt; Typename u & gt; Fixed std :: true_type tester (probe & lt; bool & gt; *); Template & lt; Typename u & gt; Fixed std :: false_type tester (...); Public: static constexpr bool value = sizeof (tester & lt; bool & gt; (0)) == size (std :: true_type); }; }  

is going to check that if var1 is present, and - quite clearly - var1 has not been complained. Honestly I am not as fluent as the use of SFINE, as I want, I remember something very simple.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -