From 2c53dc2e575133e4bad766fad780dcf97f39c5a9 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 30 Nov 2017 23:58:57 +0100 Subject: [PATCH] Investigation: failure to detect nested typedef a metafunction to detect nested typedefs worked perfectly in the test setup, but failed once included into application code. --- research/try.cpp | 79 +++++++----------------------------------------- 1 file changed, 11 insertions(+), 68 deletions(-) diff --git a/research/try.cpp b/research/try.cpp index 85f3567df..41554a164 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -35,52 +35,29 @@ // 9/17 - manipulate variadic templates to treat varargs in several chunks // 11/17 - metaprogramming to detect the presence of extension points // 11/17 - detect generic lambda +// 12/17 - investigate SFINAE failure /** @file try.cpp - ** Metaprogramming: is it possible to distinguish a generic lambda from something not a function at all? - ** Answer: not really. We can only ever check for the function call operator. - ** Even worse: if we instantiate a templated function call operator with unsuitable parameter types, - ** the compilation as such fails. Whereas SFINAE is only limited to substituting a type signature. + ** Bug hunting: a typedef detecting metafunction fails under circumstances yet to be investigated. */ typedef unsigned int uint; +#include "lib/meta/value-type-binding.hpp" +#include "lib/diff/gen-node.hpp" #include "lib/format-cout.hpp" -#include "lib/format-util.hpp" -#include "lib/meta/function.hpp" -#include "lib/test/test-helper.hpp" - -//#include -#include -#include - -using lib::meta::No_t; -using lib::meta::Yes_t; -using lib::meta::_Fun; -using lib::test::showSizeof; - -using std::function; -using std::forward; -using std::move; -using std::string; namespace lib { namespace meta{ - - template - struct ProbeFunctionInvocation - { - using Ret = decltype(std::declval() (std::declval()...)); - using Args = Types; - using Sig = Ret(ARGS...); - }; - }} -using lib::meta::enable_if; +//using lib::meta::enable_if; + +using ElmIter = lib::diff::RecordSetup::ElmIter; +using RecIter = lib::diff::Rec::iterator; #define SHOW_TYPE(_TY_) \ @@ -89,48 +66,14 @@ using lib::meta::enable_if; cout << "Probe " << STRINGIFY(_XX_) << " ? = " << _XX_ < -struct FunTrait - { - using XXX = decltype(std::declval() (0)); - - static string doIt() { return "Uh OH:" + lib::meta::typeStr(); } - }; - -template -struct FunTrait> > - { - static string doIt() { return "Yeah FUN:" + lib::meta::typeStr::Sig>(); } - }; int main (int, char**) { - auto lamb1 = [](int i) { return double(i) / (i*i); }; - auto lamb2 = [](auto i) { return double(i) / (i*i); }; + SHOW_TYPE (ElmIter); + SHOW_TYPE (RecIter); - SHOW_TYPE (decltype(lamb1)); - SHOW_TYPE (decltype(lamb2)); - - SHOW_EXPR ((_Fun::value)); - SHOW_EXPR ((_Fun::value)); - SHOW_EXPR ((_Fun::value)); - SHOW_EXPR ((_Fun::value)); - - auto funky = function (lamb2); - SHOW_EXPR ((_Fun::value)); - - cout << FunTrait::doIt() <::doIt() <::doIt() <::doIt() <::pointer); cout << "\n.gulp.\n";