IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
899B

  1. #include <utility>
  2. #include <iostream>
  3. template<template<typename T> class F, typename... Ts>
  4. void dispatch(int x, Ts&& ...args) {
  5. if (x > 0)
  6. F<int>()(std::forward<Ts>(args)...);
  7. else
  8. F<double>()(std::forward<Ts>(args)...);
  9. }
  10. template<typename T>
  11. struct bla {
  12. void operator()(int&& a, char&& b, double&& c) const {
  13. std::cout << sizeof(T) << " " << typeid(T).name() << " " << a << " " << b << " " << c << std::endl;
  14. }
  15. };
  16. template<typename T>
  17. struct bla128 {
  18. void operator()(int&& a, char&& b, __float128&& c) const {
  19. std::cout << sizeof(T) << " " << typeid(T).name() << " " << a << " " << b << " " << (double) c << std::endl;
  20. }
  21. };
  22. main() {
  23. std::cout << "main()" << std::endl;
  24. //bla<double>()(1, 'a', 5.5);
  25. dispatch<bla128, int, char, __float128>(5, 1, 'a', (__float128) 5.5);
  26. dispatch<bla, int, char, double>(-5, 1, 'a', 5.5);
  27. }