VCCC  2024.05
VisualCamp Common C++ library
c_printable.hpp
Go to the documentation of this file.
1 # /*
2 # Created by YongGyu Lee on 2020/12/08.
3 # */
4 #
5 # ifndef VCCC_LOG_DETAIL_C_PRINTABLE_HPP
6 # define VCCC_LOG_DETAIL_C_PRINTABLE_HPP
7 #
8 # include <type_traits>
9 #
10 # include "vccc/type_traits.hpp"
11 
12 namespace vccc {
13 namespace internal {
14 
15 template<typename T>
16 struct can_decay_to_scalar_impl : std::conditional<std::is_scalar<T>::value || std::is_array<T>::value,
17  std::true_type, std::false_type>::type {};
18 
19 template<typename ...Ts>
20 struct can_decay_to_scalar : conjunction<can_decay_to_scalar_impl<Ts>...> {};
21 
22 template<typename ...Ts>
23 using can_decay_to_scalar_t = typename can_decay_to_scalar<Ts...>::type;
24 
25 template<typename ...>
26 struct are_types_c_printable : std::false_type {};
27 
28 // block single type to avoid std::snprintf security warnings
29 template<typename T>
30 struct are_types_c_printable<T> : std::false_type {};
31 
32 template<typename T, typename ...Ts>
33 struct are_types_c_printable<T, Ts...>
34  : std::integral_constant<bool,
35  (std::is_same<char *, std::decay_t<T>>::value || std::is_same<const char*, std::decay_t<T>>::value) &&
36  can_decay_to_scalar<Ts...>::value> {};
37 
38 template<typename ...Ts>
39 using are_types_c_printable_t = typename are_types_c_printable<Ts...>::type;
40 
41 } // namespace internal
42 } // namespace vccc
43 
44 # endif // VCCC_LOG_DETAIL_C_PRINTABLE_HPP
Definition: directory.h:12