c++ - does sfinae instantiates a function body? -


I want to find out the existence of a specific member function for a class using the normal SFINE move.

  template & lt; Typename T & gt; Struct has_alloc {template & lt; Typename u, u x & gt; Structure dummy; Template & lt; Typename u & gt; Fixed four tests (dummy and lt; zero * (u :: *) (standard :: size_t), & amp; u :: allocated> gt; *); Template & lt; Typename u & gt; Fixed four (and test (...)) [2]; Fixed BULL CONST value = size (Trial> T & gt; (0)) == 1; }; It should be noted that it detects a different kind of allocation in which the  zero * allocation (std :: size_t)  is in the form of member functions. Which is non-standard (maybe some raw memory allocation). 

Next, I have an incomplete type and a std :: allocation for that incomplete type.

  Structure testing; Typeface Study :: Allocator & lt; Test & gt; Test_alloc;  

And I'm checking whether test_alloc is what I'm looking for.

  struct kind_of_alloc {const static bool value = is_alloc & lt; Test_alloc & gt; :: value; };  

Definitely the struct test will be completed when I type "<"> "test_alloc such as

  Will use "#include" test_def.hpp "// code located on Structure Test {}; Zero experiment () {test_alloc a; }  

In another compilation unit. However, when_alloc is tested, the compiler tries to instantiate the allocation function for std :: oscillator and finds that an incomplete type of shape is used inside the function body, and causes a hard error It appears that if the implementation of the allocated is individually and individually included at the point of use such as

  template & lt; Typename T & gt; T * Alok & lt; T & gt; :: Allocated (std :: size_t n) {Return (T *) operator new (sizeof (t) * n); } Zero experiment () {test_alloc a; A.allocate (2); }  

and test_def.hpp in

  template & lt; Typename T & gt; Structure Allocation {T * Allocated (std :: size_t n); };  

However, I did not sign in to alloc & lt; T & gt; I can do this for, std :: allocator is not possible for implementation, implementation is not possible What I am looking for It is possible to check whether the void * allocate ( Size_t) with a function exists in test_alloc or not. If not, this will do a negative test, and if yes, if the function matches the signature, even if it can not be instantiated there, positive test.

No, SFINEE is only under the overload resolution once a resolution has been created and compiler SFINAE The ending function starts to start.

Edit: And taking the address of the function immediately,


Comments