Advertisement
Guest User

Untitled

a guest
Sep 4th, 2014
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <annex/data/variant/variant.hpp>
  2.  
  3. template<int I>
  4. struct dummy {
  5.     operator int() const { return -1; }
  6. };
  7.  
  8. template<int N>
  9. int expand()
  10. {
  11.     return []<std::size_t... Indices>(std::index_sequence<Indices...>) -> auto
  12.     {
  13.         using annex::variant;
  14.         variant<dummy<Indices>..., int> v = 7;
  15.         variant<dummy<Indices>..., int> w = 8;
  16.         variant<dummy<Indices>..., int> z = 5;
  17.         auto compute = [](auto i, auto j, auto k) { return (i + j) * k; };
  18.         return apply(compute, v, w, z);
  19.     }(std::make_index_sequence<N> {});
  20. }
  21.  
  22. int main()
  23. {
  24.     return expand<40>();
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement