Sen API
Sen Libraries
Toggle main menu visibility
Loading...
Searching...
No Matches
u8string_util.h
Go to the documentation of this file.
1
// === u8string_util.h =================================================================================================
2
// Sen Infrastructure
3
// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4
// See the LICENSE.txt file for more information.
5
// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6
// =====================================================================================================================
7
8
#ifndef SEN_CORE_BASE_U8STRING_UTIL_H
9
#define SEN_CORE_BASE_U8STRING_UTIL_H
10
11
// std
12
#include <string>
13
14
namespace
sen::std_util
15
{
16
17
inline
std::string
fromU8string
(
const
std::string& s) {
return
s; }
18
19
inline
std::string
fromU8string
(std::string&& s) {
return
std::move(s); }
20
21
#if defined(__cpp_lib_char8_t)
22
inline
std::string
fromU8string
(
const
std::u8string& s) {
return
std::string(s.begin(), s.end()); }
23
#endif
24
25
inline
const
char
*
castToCharPtr
(
const
char
* cp) {
return
cp; }
26
27
#if defined(__cpp_lib_char8_t)
28
inline
const
char
*
castToCharPtr
(
const
char8_t
* cp)
29
{
30
// Safe, as lvalues of type char may be used to access values of other types
31
return
reinterpret_cast<
const
char
*
>
(cp);
// NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
32
}
33
34
#endif
35
36
}
// namespace sen::std_util
37
38
#endif
// SEN_CORE_BASE_U8STRING_UTIL_H
sen::std_util
Definition
bits.h:26
sen::std_util::fromU8string
std::string fromU8string(const std::string &s)
Definition
u8string_util.h:17
sen::std_util::castToCharPtr
const char * castToCharPtr(const char *cp)
Definition
u8string_util.h:25
libs
core
include
sen
core
base
u8string_util.h
Generated by
1.17.0