VCCC  2024.05
VisualCamp Common C++ library
key_value.hpp
Go to the documentation of this file.
1 //
2 // Created by YongGyu Lee on 2/22/24.
3 //
4 
5 #ifndef VCCC_UTILITY_KEY_VALUE_HPP
6 #define VCCC_UTILITY_KEY_VALUE_HPP
7 
8 #include <cstddef>
9 #include <tuple>
10 #include <utility>
11 
16 
17 namespace vccc {
18 namespace detail {
19 
20 template<std::size_t I>
21 struct element_niebloid {
22  template<typename T, std::enable_if_t<conjunction<
23  tuple_like<T>,
24  internal::tuple_size_greater_than<remove_cvref_t<T>, I>
25  >::value, int> = 0>
26  constexpr decltype(auto) operator()(T&& t) const noexcept {
27  return std::get<I>(std::forward<T>(t));
28  }
29 };
30 
31 } // namespace detail
32 
33 VCCC_INLINE_OR_STATIC constexpr detail::element_niebloid<0> key;
34 VCCC_INLINE_OR_STATIC constexpr detail::element_niebloid<0> first;
35 VCCC_INLINE_OR_STATIC constexpr detail::element_niebloid<1> value;
36 VCCC_INLINE_OR_STATIC constexpr detail::element_niebloid<1> second;
37 
38 template<std::size_t I>
39 VCCC_INLINE_OR_STATIC constexpr detail::element_niebloid<I> element;
40 
41 } // namespace vccc
42 
43 
44 #endif // VCCC_UTILITY_KEY_VALUE_HPP
#define VCCC_INLINE_OR_STATIC
Definition: inline_or_static.hpp:9
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > second
Definition: key_value.hpp:36
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 0 > key
Definition: key_value.hpp:33
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 0 > first
Definition: key_value.hpp:34
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< I > element
Definition: key_value.hpp:39
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35