2024-11-14 22:10:43 +01:00
|
|
|
/* try.cpp - to try out and experiment with new features....
|
2007-08-17 00:36:07 +02:00
|
|
|
* scons will create the binary bin/try
|
2014-08-16 02:04:29 +02:00
|
|
|
*/
|
2024-12-12 04:38:55 +01:00
|
|
|
// 12/24 - investigate overload resolution on a templated function similar to std::get
|
2024-11-14 22:10:43 +01:00
|
|
|
// 11/24 - how to define a bare object location comparison predicate
|
2023-11-27 21:58:37 +01:00
|
|
|
// 11/23 - prototype for grouping from iterator
|
2012-01-07 03:28:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @file try.cpp
|
2024-12-12 04:38:55 +01:00
|
|
|
* 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.
|
2012-01-07 03:28:12 +01:00
|
|
|
*/
|
|
|
|
|
|
2015-08-29 17:09:03 +02:00
|
|
|
typedef unsigned int uint;
|
|
|
|
|
|
2020-03-07 19:39:51 +01:00
|
|
|
|
2016-01-06 04:36:53 +01:00
|
|
|
#include "lib/format-cout.hpp"
|
2018-03-17 03:36:58 +01:00
|
|
|
#include "lib/test/test-helper.hpp"
|
2022-12-18 03:47:40 +01:00
|
|
|
#include "lib/test/diagnostic-output.hpp"
|
2018-08-16 21:40:10 +02:00
|
|
|
#include "lib/util.hpp"
|
2019-04-19 18:37:30 +02:00
|
|
|
|
2023-11-20 02:00:56 +01:00
|
|
|
#include <utility>
|
2024-11-14 22:10:43 +01:00
|
|
|
#include <string>
|
2024-12-12 04:38:55 +01:00
|
|
|
#include <tuple>
|
2018-08-16 21:40:10 +02:00
|
|
|
|
2024-12-12 04:38:55 +01:00
|
|
|
using lib::test::showType;
|
2022-08-28 23:36:27 +02:00
|
|
|
|
2024-12-12 04:38:55 +01:00
|
|
|
template<typename...TS>
|
|
|
|
|
string
|
|
|
|
|
showTypes()
|
|
|
|
|
{
|
|
|
|
|
return "<" + ((showType<TS>()+",") + ... + ">");
|
|
|
|
|
}
|
2023-11-20 02:00:56 +01:00
|
|
|
|
2024-12-12 04:38:55 +01:00
|
|
|
using std::tuple;
|
2023-11-27 21:58:37 +01:00
|
|
|
|
2024-12-12 04:38:55 +01:00
|
|
|
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<class...TS>
|
|
|
|
|
string getty (tuple<TS...>&) { return "getty-tuple& "+showTypes<TS...>(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<class...TS>
|
|
|
|
|
struct F : tuple<TS...> { };
|
|
|
|
|
|
|
|
|
|
template<class...TS>
|
|
|
|
|
struct FD1 : F<TS...> {};
|
|
|
|
|
|
|
|
|
|
template<class...TS>
|
|
|
|
|
struct FD2 : FD1<TS...> {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<class...TS>
|
|
|
|
|
string getty (FD1<TS...>&) { return "getty-FD1& "+showTypes<TS...>(); }
|
2019-04-19 18:37:30 +02:00
|
|
|
|
2016-01-05 03:32:24 +01:00
|
|
|
int
|
|
|
|
|
main (int, char**)
|
|
|
|
|
{
|
2024-12-12 04:38:55 +01:00
|
|
|
D2 d2;
|
|
|
|
|
SHOW_EXPR(getty(d2));
|
2024-11-14 22:10:43 +01:00
|
|
|
|
2024-12-12 04:38:55 +01:00
|
|
|
FD2<int, char**> fd2;
|
|
|
|
|
SHOW_EXPR(getty(fd2));
|
2023-11-20 02:00:56 +01:00
|
|
|
|
2018-03-30 23:55:42 +02:00
|
|
|
cout << "\n.gulp.\n";
|
2007-08-17 00:36:07 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|