OpenVPN 3 Core Library
Loading...
Searching...
No Matches
stringtempl2.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
13
#pragma once
14
15
#include <string>
16
#include <type_traits>
17
18
#include <
openvpn/common/stringtempl.hpp
>
19
20
namespace
openvpn::StringTempl
{
21
22
// empty
23
24
// for objects that define an empty method
25
template
<
typename
T>
26
inline
auto
empty
(
const
T &t) ->
decltype
(t.empty())
27
{
28
return
t.empty();
29
}
30
31
// for numerical values
32
template
<
typename
T,
33
typename
std::enable_if<std::is_arithmetic<T>::value,
int
>::type = 0>
34
inline
bool
empty
(T value)
35
{
36
return
false
;
37
}
38
39
// to_string
40
41
// for objects that define a to_string() method
42
template
<
typename
T>
43
inline
auto
to_string(
const
T &t) ->
decltype
(t.to_string())
44
{
45
return
t.to_string();
46
}
47
48
// for numerical values
49
template
<
typename
T,
50
typename
std::enable_if<std::is_arithmetic<T>::value,
int
>::type = 0>
51
inline
std::string to_string(T value)
52
{
53
return
std::to_string(value);
54
}
55
56
}
// namespace openvpn::StringTempl
openvpn::StringTempl
Definition
stringtempl.hpp:25
openvpn::StringTempl::empty
bool empty(std::nullptr_t)
Definition
stringtempl.hpp:29
stringtempl.hpp
openvpn
common
stringtempl2.hpp
Generated by
1.9.8