Horizon
cpp_future.hpp
1 #pragma once
2 
3 #include <cstddef> // size_t
4 #include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
5 
6 namespace nlohmann
7 {
8 namespace detail
9 {
10 // alias templates to reduce boilerplate
11 template<bool B, typename T = void>
12 using enable_if_t = typename std::enable_if<B, T>::type;
13 
14 template<typename T>
15 using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
16 
17 // implementation of C++14 index_sequence and affiliates
18 // source: https://stackoverflow.com/a/32223343
19 template<std::size_t... Ints>
21 {
22  using type = index_sequence;
23  using value_type = std::size_t;
24  static constexpr std::size_t size() noexcept
25  {
26  return sizeof...(Ints);
27  }
28 };
29 
30 template<class Sequence1, class Sequence2>
32 
33 template<std::size_t... I1, std::size_t... I2>
35  : index_sequence < I1..., (sizeof...(I1) + I2)... > {};
36 
37 template<std::size_t N>
39  : merge_and_renumber < typename make_index_sequence < N / 2 >::type,
40  typename make_index_sequence < N - N / 2 >::type > {};
41 
42 template<> struct make_index_sequence<0> : index_sequence<> {};
43 template<> struct make_index_sequence<1> : index_sequence<0> {};
44 
45 template<typename... Ts>
46 using index_sequence_for = make_index_sequence<sizeof...(Ts)>;
47 
48 // dispatch utility (taken from ranges-v3)
49 template<unsigned N> struct priority_tag : priority_tag < N - 1 > {};
50 template<> struct priority_tag<0> {};
51 
52 // taken from ranges-v3
53 template<typename T>
55 {
56  static constexpr T value{};
57 };
58 
59 template<typename T>
60 constexpr T static_const<T>::value;
61 } // namespace detail
62 } // namespace nlohmann
namespace for Niels Lohmann
Definition: adl_serializer.hpp:9
Definition: cpp_future.hpp:21
Definition: cpp_future.hpp:40
Definition: cpp_future.hpp:31
Definition: cpp_future.hpp:49
Definition: cpp_future.hpp:55