include
cras_cpp_common
type_utils
string_traits.hpp
Go to the documentation of this file.
1
#pragma once
2
11
#include <cstddef>
12
#include <string>
13
#include <type_traits>
14
15
namespace
cras
16
{
17
22
template
<
typename
T>
23
struct
is_c_string
:
public
std::false_type {};
24
25
template
<>
26
struct
is_c_string
<char*> :
public
std::true_type {};
27
28
template
<>
29
struct
is_c_string
<char*
const
> :
public
std::true_type {};
30
31
template
<>
32
struct
is_c_string
<const char*> :
public
std::true_type {};
33
34
template
<>
35
struct
is_c_string
<const char*
const
> :
public
std::true_type {};
36
37
template
<
int
I>
38
struct
is_c_string
<char[I]> :
public
std::true_type {};
39
40
template
<
int
I>
41
struct
is_c_string
<const char[I]> :
public
std::true_type {};
42
47
template
<
typename
T,
typename
=
void
>
48
struct
is_string
:
public
std::false_type {};
49
50
template
<
typename
T>
51
struct
is_string
<T, ::std::enable_if_t<::cras::is_c_string<typename std::decay<T>::type>::value>> :
52
public
std::true_type {};
53
54
template
<
typename
T>
55
struct
is_string
<T, ::std::enable_if_t<::std::is_same<typename std::decay<T>::type, ::std::string>::value>> :
56
public
std::true_type {};
57
58
}
cras::is_c_string
Type trait for dynamic-sized and constant-sized C strings.
Definition:
string_traits.hpp:23
cras
Definition:
any.hpp:15
cras::is_string
Char trait for a C-string or std::string.
Definition:
string_traits.hpp:48
cras_cpp_common
Author(s): Martin Pecka
autogenerated on Tue Nov 26 2024 03:49:04