Vcsn  2.2a
Be Rational
static-if.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utility>
4 
6 
7 namespace vcsn
8 {
9  namespace detail
10  {
12  template <typename Then, typename Else>
13  auto static_if(std::true_type, Then&& then, Else&&)
14  {
15  return std::forward<Then>(then);
16  }
17 
19  template <typename Then, typename Else>
20  auto static_if(std::false_type, Then&&, Else&& else_)
21  {
22  return std::forward<Else>(else_);
23  }
24 
26  template <bool cond, typename Then, typename Else>
27  auto static_if(Then&& then, Else&& else_)
28  {
30  std::forward<Then>(then),
31  std::forward<Else>(else_));
32  }
33 
35  template <bool cond, typename Then>
36  auto static_if(Then&& then)
37  {
38  return static_if<cond>(std::forward<Then>(then),
39  [](auto&&...){});
40  }
41  }
42 }
auto static_if(std::true_type, Then &&then, Else &&)
Execute the then-clause.
Definition: static-if.hh:13
std::integral_constant< bool, B > bool_constant
Definition: type_traits.hh:12
Definition: a-star.hh:8