diff --git a/research/try.cpp b/research/try.cpp index 6a18af5c0..bf14e0ec9 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -45,14 +45,15 @@ typedef unsigned int uint; #include "lib/format-cout.hpp" #include "lib/format-util.hpp" -//#include "lib/meta/function.hpp" +#include "lib/meta/duck-detector.hpp" #include "lib/test/test-helper.hpp" #include #include #include -//using lib::meta::_Fun; +using lib::meta::No_t; +using lib::meta::Yes_t; using lib::test::showSizeof; using std::function; @@ -65,38 +66,81 @@ using std::string; #define SHOW_TYPE(_TY_) \ cout << "typeof( " << STRINGIFY(_TY_) << " )= " << lib::meta::typeStr<_TY_>() <()))> -struct Probe +class Cheesy { }; +class Fishy + { + friend void fun1 (Fishy&); + }; + +#define META_DETECT_EXTENSION_POINT(_FUN_) \ + template \ + class HasExtensionPoint_##_FUN_ \ + { \ + template()))>\ + struct Probe \ + { }; \ + \ + template \ + static Yes_t check(Probe * ); \ + template \ + static No_t check(...); \ + \ + public: \ + static const bool value = (sizeof(Yes_t)==sizeof(check(0))); \ + }; + + +META_DETECT_EXTENSION_POINT (fun) +META_DETECT_EXTENSION_POINT (fun1) int main (int, char**) { fun1 (23); - fun2 (); + fun1 (); - using Ty1 = decltype (fun1(12)); - using Ty2 = decltype (fun2()); + SHOW_EXPR ( HasExtensionPoint_fun::value ); + SHOW_EXPR ( HasExtensionPoint_fun1::value ); + SHOW_EXPR ( HasExtensionPoint_fun1::value ); + SHOW_EXPR ( HasExtensionPoint_fun1::value ); + SHOW_EXPR ( HasExtensionPoint_fun1::value ); + SHOW_EXPR ( HasExtensionPoint_fun1::value ); + SHOW_EXPR ( HasExtensionPoint_fun1::value ); + SHOW_EXPR ( HasExtensionPoint_fun1::value ); + SHOW_EXPR ( HasExtensionPoint_fun1::value ); - cout << "siz-1="<< sizeof(Ty1)<