libshit

Just some random shit
git clone https://git.neptards.moe/neptards/libshit.git
Log | Files | Refs | Submodules | README | LICENSE

xstring (2224B)


      1 // -*- c++ -*-
      2 #pragma once
      3 
      4 #include <type_traits>
      5 #include <xmemory0>
      6 
      7 namespace std
      8 {
      9   template <typename Char, typename Traits = char_traits<Char>>
     10   class basic_string_view;
     11 }
     12 
     13 // make default ctor noexcept
     14 #pragma push_macro("basic_string")
     15 #define basic_string() \
     16   basic_string() noexcept _Pragma("pop_macro(\"basic_string\")")
     17 
     18 #pragma push_macro("basic_string")
     19 #define basic_string(...)   \
     20   basic_string(__VA_ARGS__) _Pragma("pop_macro(\"basic_string\")")
     21 
     22 #pragma push_macro("basic_string")
     23 #define basic_string(...)   \
     24   basic_string(__VA_ARGS__) _Pragma("pop_macro(\"basic_string\")")
     25 
     26 
     27 #define traits_type traits_type; \
     28   constexpr _Elem* data() noexcept { return _Myptr(); }                        \
     29                                                                                \
     30   template <typename T, typename = std::enable_if_t<                           \
     31     std::is_convertible_v<const T&, std::basic_string_view<_Elem, _Traits>> && \
     32     !std::is_convertible_v<const T&, const _Elem*>>>                           \
     33   basic_string& append(const T& t)                                             \
     34   {                                                                            \
     35     std::basic_string_view<_Elem, _Traits> sv = t;                             \
     36     return append(sv.data(), sv.size());                                       \
     37   }                                                                            \
     38                                                                                \
     39   template <typename T, typename = std::enable_if_t<                           \
     40     std::is_convertible_v<const T&, std::basic_string_view<_Elem, _Traits>> && \
     41     !std::is_convertible_v<const T&, const _Elem*>>>                           \
     42   basic_string& operator+=(const T& t)                                         \
     43   {                                                                            \
     44     std::basic_string_view<_Elem, _Traits> sv = t;                             \
     45     return append(sv.data(), sv.size());                                       \
     46   }                                                                            \
     47 
     48 #include_next <xstring>
     49 #undef traits_type