UniRec  3.2.0
unirecTypeTraits.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include <string>
12 #include <string_view>
13 #include <type_traits>
14 
15 namespace Nemea {
16 
17 // NOLINTBEGIN
18 
25 template<typename T>
26 struct is_string : std::false_type {};
27 
28 template<>
29 struct is_string<std::string> : std::true_type {};
30 
31 template<>
32 struct is_string<std::string_view> : std::true_type {};
33 
34 template<typename T>
36 
44 template<typename T>
45 struct add_const {
46  using type = T;
47 };
48 
49 template<typename T>
50 struct add_const<T*> {
51  using type = const T*;
52 };
53 
54 template<typename T>
55 struct add_const<T&> {
56  using type = const T&;
57 };
58 
59 template<typename T>
61 
62 // NOLINTEND
63 
64 } // namespace Nemea
typename add_const< T >::type add_const_t
constexpr bool is_string_v
A type trait that adds const to a given type if it is a pointer or a reference.
A type trait that checks if a given type is a string type.