c++ - Checking whether a non-hardwired member function exists with SFINAE -
I want to make a proxy for member functions and operators. They should have the same return type and parameter, and should be good for many classes, which are given as template parameters, even if there is no specific member function or operator in the class, I want to compile instead of failing error, essentially any method of SFINE if Removing the return type from a known function is no longer a problem, after this there is no such error, if there is no such work. I already know whether a function exists or not, and I have several template metaprogramming tricks to enable fixed feature, however, they all work only hard work rather than hard working people On names, which severely limit your use in this case, because I need to do the same construction for many tasks. I just need to see that there is no function with the given name or there is no overloaded version. I do not need to see if a specific exists or not, the automatic template cut solves it. (Either I hope) My current code looks like this: Which compile, even if the function does not have a name in T. Unfortunately both versions fail with an error. Implementation of the result < / P> I doubt that should trigger SFINEE and discard any acceleration of It should not be so, it is possible to use for which my compiler will happily I recommend using the freestanding form of operators wherever possible: There is a possibility. X is a method
f and
y If not, then its name is
f is, give me the
proxy & lt; X & gt;
X :: f as a
f () as well, and give me the
proxy & lt; Y & gt;
template & lt; Class T & gt; Class proxy {// solution to my result template & lt; Class ... Args & gt; Results (T: F, RGS ...) F (RGS ... x) {Return XF (x ...); } // Use another return type extraction solution template & lt; Class ... Args & gt; Typef (T: F (STD :: Develel & LT; ARGEE & gt; () ... F (ARGS ... X) {Return X.F. (X ...);} T x;};
#define results (f, ...) typeof (Ultimate <__VA_ARGS __ & gt; :: Func f)) Template & lt; Class ... Args & gt; Class pauses {public: templates & lt; Class R & gt; Stable R. Funk (R (*) (RGS ...)); Template & lt; Class R, Class C & gt; Stable R Funk (R (C :: *) (RGS ...)); Template & lt; Class R, Class C & gt; Stable R. Funk (R (C: *) (RGS ...)); };
template & lt ; Typename .. args & gt; Decltype (std :: declval & lt; t & gt; () .f (std :: declval & lt; ergus & gt; () ...) F (arg and amp) {return xf (Std :: forward & lt; args & gt; (args) ...); }
f for which the type of return was made ill rather than bad Is (like ambiguous or non-present overload) error I am not completely sure, because
T is the parameter of a
proxy , not
f and I can not parse the related parts of the bus standard ( About 14.8.2 I believe). None of the examples given in non-authentic notes are applicable.
template & lt; Typename u = t &, typename ... args & gt; Decltype (std :: declval & lt; U & gt; () .f (std :: declval & lt; ARGS & gt; () ...) F (ARGs & AGRG) {return xf (std: : Forward & lt; ergos & gt; (args) ...); }
proxy & lt; Int & gt; Accepts P; , is not the opposite of the first option.
PF (); In the results 'no matching ceremony was found' error, as is normal with SFINE.
template & lt; Typename t, typename u & gt; Auto operator + (Proxy & lt; T & gt; Cons & amp; LHS, Proxy & lt; U & gt; Const & amp; rhs) - & gt; Decltype (std :: declval & lt; t const & gt; () + std :: declval & lt; u const & gt; ()) {Return lhs.x + rhs.x; }
Comments
Post a Comment