Vcsn  2.3
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 #if (defined __clang__ && __clang_major__ == 3 && __clang_minor__ < 6 \
40  || defined __GNUC__ && !defined __clang__ && __GNUC__ < 5)
41  // Clang 3.5 and GCC 4.9 require that we name the argument.
42  [](auto&&... argss){}
43 #else
44  [](auto&&...){}
45 #endif
46  );
47  }
48  }
49 }
auto static_if(std::true_type, Then &&then, Else &&)
Execute the then-clause.
Definition: static-if.hh:13
Definition: a-star.hh:8
std::integral_constant< bool, B > bool_constant
Definition: type_traits.hh:12