You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
2.2 KiB
C++
50 lines
2.2 KiB
C++
// -*- c++ -*-
|
|
#pragma once
|
|
|
|
#include <type_traits>
|
|
#include <xmemory0>
|
|
|
|
namespace std
|
|
{
|
|
template <typename Char, typename Traits = char_traits<Char>>
|
|
class basic_string_view;
|
|
}
|
|
|
|
// make default ctor noexcept
|
|
#pragma push_macro("basic_string")
|
|
#define basic_string() \
|
|
basic_string() noexcept _Pragma("pop_macro(\"basic_string\")")
|
|
|
|
#pragma push_macro("basic_string")
|
|
#define basic_string(...) \
|
|
basic_string(__VA_ARGS__) _Pragma("pop_macro(\"basic_string\")")
|
|
|
|
#pragma push_macro("basic_string")
|
|
#define basic_string(...) \
|
|
basic_string(__VA_ARGS__) _Pragma("pop_macro(\"basic_string\")")
|
|
|
|
|
|
#define traits_type traits_type; \
|
|
constexpr _Elem* data() noexcept { return _Myptr(); } \
|
|
\
|
|
template <typename T, typename = std::enable_if_t< \
|
|
std::is_convertible_v<const T&, std::basic_string_view<_Elem, _Traits>> && \
|
|
!std::is_convertible_v<const T&, const _Elem*>>> \
|
|
basic_string& append(const T& t) \
|
|
{ \
|
|
std::basic_string_view<_Elem, _Traits> sv = t; \
|
|
return append(sv.data(), sv.size()); \
|
|
} \
|
|
\
|
|
template <typename T, typename = std::enable_if_t< \
|
|
std::is_convertible_v<const T&, std::basic_string_view<_Elem, _Traits>> && \
|
|
!std::is_convertible_v<const T&, const _Elem*>>> \
|
|
basic_string& operator+=(const T& t) \
|
|
{ \
|
|
std::basic_string_view<_Elem, _Traits> sv = t; \
|
|
return append(sv.data(), sv.size()); \
|
|
} \
|
|
|
|
#include_next <xstring>
|
|
#undef traits_type
|