VCCC  2024.05
VisualCamp Common C++ library
convert_to.hpp
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2020/12/08.
3 # */
4 #
5 # ifndef VCCC_TYPE_SUPPORT_CONVERT_HPP
6 # define VCCC_TYPE_SUPPORT_CONVERT_HPP
7 #
10 
11 namespace vccc {
12 
66 inline std::enable_if_t<disjunction<is_tuple_like<To>, is_tuple_like<From>>::value, To>
67 convert_to(const From& from)
68 {
69  const auto v1 = is_tuple_like<To>::value;
70  const auto v2 = is_tuple_like<From>::value;
73  using Indices = typename std::make_index_sequence<
77  return internal::convert_to_impl<To>(is_tuple_like<To>(), from, Indices{});
78 }
79 
92 inline std::enable_if_t<disjunction<is_tuple_like<To>, is_tuple_like<From>>::value, To>
93 convert_to(const From& from)
94 {
96  "Converting size must be smaller than converting type's tuple_size");
98  "Converting size must be smaller than original type's tuple_size");
99 
100  return internal::convert_to_impl<To>(is_tuple_like<To>{}, from, std::make_index_sequence<n>{});
101 }
102 
106 template<typename To> inline decltype(auto) convert_to( To&& from) { return std::forward<To>(from); }
107 template<typename To> inline To convert_to(const To& from) { return from; }
108 
110 
111 } // namespace vccc
112 
113 # endif // VCCC_TYPE_SUPPORT_CONVERT_HPP
std::enable_if_t< disjunction< is_tuple_like< To >, is_tuple_like< From > >::value, To > convert_to(const From &from)
Definition: convert_to.hpp:67
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35
Check if type is tuple-like(deprecated. Use tuple_like instead)
Definition: is_tuple_like.hpp:18
Definition: numeric.hpp:116