Lumiera  0.pre.03
»edit your freedom«
DuckDetectorExtension_test Class Reference

Description

Test:
demonstrate some details regarding detection of functions within a type.

The purpose of these metaprogramming techniques is to write generic containers, handlers, iterators etc, which automatically adapt themselves to the abilities of their payload type. To give an example, we may investigate the argument type of a functor or lambda, and then compose it with a suitable adapter or converter to work with the given data.

However, when it comes to detecting the presence of a specific function, there are some complexities and variations to consider. Sometimes we only want to check for the presence of some function, while in other cases we also want to verify the exact signature of that function. Moreover, some of these detection techniques break down whenever there is overload ambiguity; thus we might need to resort to an alternative, not so strict test to get past such limitations.

Definition at line 90 of file duck-detector-extension-test.cpp.

Private Member Functions

void detect_freeFunctionADL_ExtensionPoint ()
 
void detect_memberFunctionVariations ()
 
 META_DETECT_EXTENSION_POINT (funZ)
 
 META_DETECT_EXTENSION_POINT (fun)
 
 META_DETECT_FUNCTION (double, funny,(char, char, string))
 
 META_DETECT_FUNCTION (llong, fuzzy,(void))
 
 META_DETECT_FUNCTION_ARGLESS (funny)
 
 META_DETECT_FUNCTION_ARGLESS (funky)
 
 META_DETECT_FUNCTION_ARGLESS (fuzzy)
 
 META_DETECT_FUNCTION_NAME (funny)
 
 META_DETECT_FUNCTION_NAME (funky)
 
 META_DETECT_FUNCTION_NAME (fuzzy)
 
 META_DETECT_FUNCTION_NAME (fully)
 
 META_DETECT_MEMBER (funny)
 
 META_DETECT_MEMBER (funky)
 
 META_DETECT_MEMBER (fuzzy)
 
 META_DETECT_MEMBER (fully)
 
void run (Arg)
 

Member Function Documentation

◆ detect_freeFunctionADL_ExtensionPoint()

void detect_freeFunctionADL_ExtensionPoint ( )
inlineprivate
Test:
detect the presence of a free function extension point at compile time.

It is a common idiom in C++ to expose an extension point through a free function, which is expected to be picked up by ADL. To mention a prominent example, any type can offer the ability to be iterated by injecting free functions begin(TY) and end(TY), to yield a STL compatible iterator.

Since such an extension point is used just by invoking the unqualified function with the target type, we can build a meta predicate based on the fact if such an function invocation expression can be formed for the type in question.

Note
the test really hinges on the ability to form the extension point call. For this reason, some implicit conversions might be involved, and some other conversions won't work (like passing a value to an extension point taking a reference).

Definition at line 135 of file duck-detector-extension-test.cpp.

◆ detect_memberFunctionVariations()

void detect_memberFunctionVariations ( )
inlineprivate
Test:
cover variations of member function detection
  • detect an explicitly given full signature
  • detect just the presence of a function name
  • distinguish this from detecting a member
  • detect especially a member function without arguments
Note
some corner cases are demonstrated here as well:
  • private functions can not be detected
  • detection fails on ambiguity due to overloads

Definition at line 172 of file duck-detector-extension-test.cpp.

+ Inheritance diagram for DuckDetectorExtension_test:
+ Collaboration diagram for DuckDetectorExtension_test:

The documentation for this class was generated from the following file: