VCCC  2024.05
VisualCamp Common C++ library
traits.h
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2021/05/24.
3 # */
4 #
5 # ifndef VCCC_OPTIONAL_INTERNAL_TRAITS_H_
6 # define VCCC_OPTIONAL_INTERNAL_TRAITS_H_
7 #
8 # include <type_traits>
9 
10 namespace vccc {
11 namespace internal {
12 namespace optional {
13 
14 template<bool v>
15 struct conditional_tf : std::conditional_t<v, std::true_type, std::false_type> {};
16 
17 template<bool v>
18 using conditional_tf_t = typename conditional_tf<v>::type;
19 
20 template<typename Original, typename Other>
21 struct check_constructible :
22  conditional_tf_t<
23  !std::is_constructible<Original, Other & >::value && !std::is_constructible<Original, Other const& >::value &&
24  !std::is_constructible<Original, Other &&>::value && !std::is_constructible<Original, Other const&&>::value> {};
25 
26 template<typename Original, typename Other>
27 struct check_convertible :
28  conditional_tf_t<
29  !std::is_convertible<Other & , Original>::value && !std::is_convertible<Other const& , Original>::value &&
30  !std::is_convertible<Other &&, Original>::value && !std::is_convertible<Other const&&, Original>::value> {};
31 
32 template<typename Original, typename Other>
33 struct check_assignable :
34  conditional_tf_t<
35  !std::is_assignable<Original&, Other & >::value && !std::is_assignable<Original&, Other const& >::value &&
36  !std::is_assignable<Original&, Other &&>::value && !std::is_assignable<Original&, Other const&&>::value> {};
37 
38 template<typename T>
39 struct strip {
40 #if __cplusplus <= 201703
41  using type = std::decay_t<T>;
42 #else
43  using type = std::remove_cvref_t<T>;
44 # endif
45 };
46 
47 template<typename T>
48 using strip_t = typename strip<T>::type;
49 
50 } // namespace optional
51 } // namespace internal
52 } // namespace vccc
53 
54 # endif // VCCC_OPTIONAL_INTERNAL_TRAITS_H_
Definition: directory.h:12