Vcsn  2.2
Be Rational
military-order.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <tuple>
4 
5 #include <vcsn/misc/type_traits.hh> // detect
6 
7 namespace vcsn
8 {
9 
10  namespace detail
11  {
12  template <typename T>
13  using test_t = decltype(std::declval<T>().size());
14 
16  template <typename T>
18  }
19 
20 
27  template <typename T>
29  {
30  public:
31  bool operator()(const T& x, const T& y) const
32  {
33  return lt_<T>(x, y);
34  }
35 
36  private:
38  template <typename T2>
39  auto lt_(const T2& x, const T2& y) const
40  -> std::enable_if_t<detail::has_size_mem_fn<T2>::value, bool>
41  {
42  return
43  std::forward_as_tuple(x.size(), x) < std::forward_as_tuple(y.size(), y);
44  }
45 
47  template <typename T2>
48  auto lt_(const T2& x, const T2& y) const
49  -> std::enable_if_t<!detail::has_size_mem_fn<T2>::value, bool>
50  {
51  return x < y;
52  }
53  };
54 }
Definition: a-star.hh:8
decltype(std::declval< T >().size()) test_t
bool operator()(const T &x, const T &y) const
auto lt_(const T2 &x, const T2 &y) const -> std::enable_if_t< detail::has_size_mem_fn< T2 >::value, bool >
Case where T features a size() member function.
Military strict order predicate.
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
auto lt_(const T2 &x, const T2 &y) const -> std::enable_if_t<!detail::has_size_mem_fn< T2 >::value, bool >
Case where T does not feature a size() member function.