Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
join.hh
Go to the documentation of this file.
1 #ifndef VCSN_CORE_JOIN_HH
2 # define VCSN_CORE_JOIN_HH
3 
4 # include <vcsn/misc/type_traits.hh>
5 
6 namespace vcsn
7 {
8  namespace detail
9  {
10 
17  template <typename V1, typename V2,
18  typename Enable = void>
19  struct join_impl
20  {};
21 
25  template <typename V1, typename V2>
27  join_(V1 v1, V2 v2, int)
28  {
29  return join_impl<V1, V2>::join(v1, v2);
30  }
31 
32  template <typename V1, typename V2>
33  typename join_impl<V1, V2>::type
34  join_(V2 v2, V1 v1, long)
35  {
36  return join_impl<V1, V2>::join(v1, v2);
37  }
38  }
39 
42  template <typename ValueSet>
43  auto
44  join(const ValueSet& vs)
45  -> ValueSet
46  {
47  return vs;
48  }
49 
51  template <typename ValueSet1, typename ValueSet2, typename... VSs>
52  auto
53  join(const ValueSet1& vs1, const ValueSet2& vs2, const VSs&... vs)
54  -> decltype(join(detail::join_(vs1, vs2, 0), vs...))
55  {
56  return join(detail::join_(vs1, vs2, 0), vs...);
57  }
58 
60  template <typename... ValueSets>
61  using join_t = decltype(join(std::declval<ValueSets>()...));
62 }
63 
67 #define VCSN_JOIN_SIMPLE(Lhs, Rhs) \
68  \
69  template <> \
70  struct join_impl<Lhs, Rhs> \
71  { \
72  using type = Rhs; \
73  static type join(Lhs, Rhs) \
74  { \
75  return {}; \
76  } \
77  }
78 
79 
80 #endif // !VCSN_CORE_JOIN_HH
decltype(join(std::declval< ValueSets >()...)) join_t
The type of the join of the ValueSets.
Definition: join.hh:61
auto join(const ValueSet1 &vs1, const ValueSet2 &vs2, const VSs &...vs) -> decltype(join(detail::join_(vs1, vs2, 0), vs...))
The join of two (or more) valuesets.
Definition: join.hh:53
join_impl< V1, V2 >::type join_(V1 v1, V2 v2, int)
Dealing with commutativity: two implementations of join_: forward and reversed, ordered by preference...
Definition: join.hh:27
A structure that implements the computation of join(V1, V2).
Definition: join.hh:19
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
Definition: join.hh:44