/* try.cpp - to try out and experiment with new features.... * scons will create the binary bin/try */ // 12/24 - investigate overload resolution on a templated function similar to std::get // 11/24 - how to define a bare object location comparison predicate // 11/23 - prototype for grouping from iterator /** @file try.cpp * Find out about the conditions when an overload of a function template is picked. * This is an investigation regarding the proper way to overload std::get * especially when the base class of the custom type itself is a tuple. */ typedef unsigned int uint; #include "lib/format-cout.hpp" #include "lib/test/test-helper.hpp" #include "lib/test/diagnostic-output.hpp" #include "lib/util.hpp" #include #include #include using lib::test::showType; template string showTypes() { return "<" + ((showType()+",") + ... + ">"); } using std::tuple; struct B { }; struct D1 : B { }; struct D2 : D1 { }; string getty (B&) { return "getty-B&"; } string getty (D1&&){ return "getty-D1&&"; } string getty (D1&) { return "getty-D1&"; } template string getty (tuple&) { return "getty-tuple& "+showTypes(); } template struct F : tuple { }; template struct FD1 : F {}; template struct FD2 : FD1 {}; template string getty (FD1&) { return "getty-FD1& "+showTypes(); } int main (int, char**) { D2 d2; SHOW_EXPR(getty(d2)); FD2 fd2; SHOW_EXPR(getty(fd2)); cout << "\n.gulp.\n"; return 0; }