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