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.

26 lines
635B

  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 << typeid(T).name() << " " << a << " " << b << " " << c << std::endl;
  14. }
  15. };
  16. main() {
  17. std::cout << "main()" << std::endl;
  18. //bla<double>()(1, 'a', 5.5);
  19. dispatch<bla, int, char, double>(5, 1, 'a', 5.5);
  20. dispatch<bla, int, char, double>(-5, 1, 'a', 5.5);
  21. }