Advertisement
Guest User

Different Behaviour

a guest
Jun 25th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. // MatrixMeta.hpp
  2.  
  3. #include <tuple>
  4.  
  5. template <size_t x = 0>
  6. class M;
  7.  
  8. // Note, if this is removed the problem disappears
  9. namespace meta
  10. {
  11.  
  12.     inline auto f()
  13.     {
  14.         return std::make_tuple();
  15.     }
  16.  
  17.     template <size_t x, typename ... Args>
  18.     auto f(const M<x>& , Args && ... args)
  19.     {
  20.         return f(args...);
  21.     }
  22.  
  23.     template <typename ... Args>
  24.     auto f(const M<>& first, Args && ... args)
  25.     {
  26.             return std::tuple_cat(std::make_tuple(first), f(args...));
  27.     }
  28. }
  29.  
  30. // Matrix.hpp
  31. template <size_t x>
  32. class M{};
  33.  
  34. template <>
  35. class M<0>{};
  36.  
  37. // main.cpp
  38.  
  39. int main(int, char* [])
  40. {
  41.  
  42.     M<1> a;
  43.     M<> b;
  44.  
  45.     return std::tuple_size<decltype(meta::f(a, b, b))>::value; // (0, 0)
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement