Vcsn  2.2
Be Rational
join.hh
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace vcsn
6 {
7  namespace detail
8  {
9 
16  template <typename V1, typename V2,
17  typename Enable = void>
18  struct join_impl
19  {};
20 
24  template <typename V1, typename V2>
26  join_(V1 v1, V2 v2, int)
27  {
28  return join_impl<V1, V2>::join(v1, v2);
29  }
30 
31  template <typename V1, typename V2>
33  join_(V2 v2, V1 v1, long)
34  {
35  return join_impl<V1, V2>::join(v1, v2);
36  }
37  }
38 
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>
52  auto
53  join(ValueSet1 vs1, ValueSet2 vs2)
54  -> decltype(detail::join_(vs1, vs2, 0))
55  {
56  return detail::join_(vs1, vs2, 0);
57  }
58 
68  template <typename ValueSet1, typename ValueSet2, typename ValueSet3,
69  typename... VSs>
70  auto
71  join(ValueSet1 vs1, ValueSet2 vs2, ValueSet3 vs3, VSs&&... vs)
72  -> decltype(join(join(vs1, vs2), vs3, std::forward<VSs>(vs)...))
73  {
74  return join(join(vs1, vs2), vs3, std::forward<VSs>(vs)...);
75  }
76 
78  template <typename... ValueSets>
79  using join_t = decltype(join(std::declval<ValueSets>()...));
80 }
81 
85 #define VCSN_JOIN_SIMPLE(Lhs, Rhs) \
86  \
87  template <> \
88  struct join_impl<Lhs, Rhs> \
89  { \
90  using type = Rhs; \
91  static type join(Lhs, Rhs) \
92  { \
93  return {}; \
94  } \
95  }
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
Definition: join.hh:44
decltype(join(std::declval< ValueSets >()...)) join_t
The type of the join of the ValueSets.
Definition: join.hh:79
Definition: a-star.hh:8
std::string type(const automaton &a)
The implementation type of a.
Definition: others.cc:206
A structure that implements the computation of join(V1, V2).
Definition: join.hh:18
auto join(ValueSet1 vs1, ValueSet2 vs2, ValueSet3 vs3, VSs &&...vs) -> decltype(join(join(vs1, vs2), vs3, std::forward< VSs >(vs)...))
The join of three (or more) valuesets.
Definition: join.hh:71
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:26