Types.hh
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include <string>
7 #include <boost/range/irange.hpp>
8 
9 namespace boca
10 {
11 
17 template<typename Integer>
18 decltype(auto) IntegerRange(Integer last) {
19  return boost::integer_range<Integer>(0, last);
20 }
21 
22 template<typename Integer>
23 decltype(auto) IntegerRange(Integer first, Integer last) {
24  BOOST_ASSERT( first <= last );
25  return boost::integer_range<Integer>(first, last);
26 }
27 
28 template <typename Enumeration>
29 decltype(auto) to_int(Enumeration value) {
30  return static_cast<typename std::underlying_type<Enumeration>::type>(value);
31 }
32 
33 template <typename Enumeration>
34 using Unsigned = typename std::make_unsigned<typename std::underlying_type<Enumeration>::type>;
35 
36 template <typename Enumeration>
37 decltype(auto) to_unsigned(Enumeration value) {
38  return static_cast<typename Unsigned<Enumeration>::type>(value);
39 }
40 
41 // @}
42 
43 }
decltype(auto) IntegerRange(Integer last)
Definition: Types.hh:18
decltype(auto) to_int(Enumeration value)
Definition: Types.hh:29
Boosted Collider Analysis.
Definition: Analysis.hh:15
typename std::make_unsigned< typename std::underlying_type< Enumeration >::type > Unsigned
Definition: Types.hh:34
decltype(auto) to_unsigned(Enumeration value)
Definition: Types.hh:37