|
- #include <utility>
- #include <iostream>
-
- template<template<typename T> class F, typename... Ts>
- void dispatch(int x, Ts&& ...args) {
- if (x > 0)
- F<int>()(std::forward<Ts>(args)...);
- else
- F<double>()(std::forward<Ts>(args)...);
- }
-
- template<typename T>
- struct bla {
- void operator()(int&& a, char&& b, double&& c) const {
- std::cout << sizeof(T) << " " << typeid(T).name() << " " << a << " " << b << " " << c << std::endl;
- }
- };
-
- template<typename T>
- struct bla128 {
- void operator()(int&& a, char&& b, __float128&& c) const {
- std::cout << sizeof(T) << " " << typeid(T).name() << " " << a << " " << b << " " << (double) c << std::endl;
- }
- };
-
- main() {
- std::cout << "main()" << std::endl;
- //bla<double>()(1, 'a', 5.5);
- dispatch<bla128, int, char, __float128>(5, 1, 'a', (__float128) 5.5);
- dispatch<bla, int, char, double>(-5, 1, 'a', 5.5);
- }
|