diff --git a/include/boost/fixed_string/config.hpp b/include/boost/fixed_string/config.hpp index b7cae89..e3f9cac 100644 --- a/include/boost/fixed_string/config.hpp +++ b/include/boost/fixed_string/config.hpp @@ -11,7 +11,7 @@ #define BOOST_FIXED_STRING_CONFIG_HPP // Are we dependent on Boost? -//#define BOOST_FIXED_STRING_USE_BOOST +#define BOOST_FIXED_STRING_USE_BOOST // C++ version #if __cplusplus >= 201703L diff --git a/include/boost/fixed_string/detail/fixed_string.hpp b/include/boost/fixed_string/detail/fixed_string.hpp index d1d3df4..9442f7d 100644 --- a/include/boost/fixed_string/detail/fixed_string.hpp +++ b/include/boost/fixed_string/detail/fixed_string.hpp @@ -19,6 +19,9 @@ namespace boost { namespace fixed_string { namespace detail { +template +class fixed_string; + // Because k-ballo said so template using is_input_iterator = @@ -26,6 +29,7 @@ using is_input_iterator = ! std::is_integral::value>; template +inline int lexicographical_compare( CharT const* s1, std::size_t n1, @@ -43,6 +47,7 @@ lexicographical_compare( #ifdef BOOST_FIXED_STRING_STRING_VIEW template +inline int lexicographical_compare( basic_string_view s1, @@ -53,8 +58,20 @@ lexicographical_compare( } #endif +template +inline +int +lexicographical_compare( + const fixed_string& s1, + CharT const* s2, std::size_t n2) +{ + return detail::lexicographical_compare< + CharT, Traits>(s1.data(), s1.size(), s2, n2); +} + #ifdef BOOST_FIXED_STRING_STRING_VIEW template +inline int lexicographical_compare( basic_string_view s1, @@ -65,6 +82,17 @@ lexicographical_compare( } #endif +template +inline +int +lexicographical_compare( + const fixed_string& s1, + const fixed_string& s2) +{ + return detail::lexicographical_compare( + s1.data(), s1.size(), s2.data(), s2.size()); +} + // Maximum number of characters in the decimal // representation of a binary number. This includes // the potential minus sign. @@ -78,6 +106,7 @@ max_digits(std::size_t bytes) } template +inline CharT* raw_to_string( CharT* buf, Integer x, std::true_type) @@ -103,6 +132,7 @@ raw_to_string( } template +inline CharT* raw_to_string( CharT* buf, Integer x, std::false_type) @@ -122,6 +152,7 @@ template< typename CharT, class Integer, typename Traits = std::char_traits> +inline CharT* raw_to_string(CharT* last, std::size_t size, Integer i) { @@ -132,10 +163,11 @@ raw_to_string(CharT* last, std::size_t size, Integer i) } template< - typename Traits, - typename CharT, - typename ForwardIt> - ForwardIt + typename Traits, + typename CharT, + typename ForwardIt> +inline +ForwardIt find_not_of( ForwardIt first, ForwardIt last, const CharT* str, std::size_t n) noexcept { diff --git a/include/boost/fixed_string/fixed_string.hpp b/include/boost/fixed_string/fixed_string.hpp index c79046d..694d599 100644 --- a/include/boost/fixed_string/fixed_string.hpp +++ b/include/boost/fixed_string/fixed_string.hpp @@ -1954,30 +1954,35 @@ private: template< std::size_t N, std::size_t M, typename CharT, typename Traits> +inline void operator+( fixed_stringconst& lhs, fixed_stringconst& rhs) = delete; template +inline void operator+( CharT const* lhs, fixed_stringconst& rhs) = delete; template +inline void operator+( CharT lhs, fixed_string const& rhs) = delete; template +inline void operator+( fixed_string const& lhs, CharT const* rhs) = delete; template +inline void operator+( fixed_string const& lhs, @@ -1992,6 +1997,7 @@ operator+( template< std::size_t N, std::size_t M, typename CharT, typename Traits> +inline bool operator==( fixed_string const& lhs, @@ -2003,6 +2009,7 @@ operator==( template< std::size_t N, std::size_t M, typename CharT, typename Traits> +inline bool operator!=( fixed_string const& lhs, @@ -2014,6 +2021,7 @@ operator!=( template< std::size_t N, std::size_t M, typename CharT, typename Traits> +inline bool operator<( fixed_string const& lhs, @@ -2025,6 +2033,7 @@ operator<( template< std::size_t N, std::size_t M, typename CharT, typename Traits> +inline bool operator<=( fixed_string const& lhs, @@ -2036,6 +2045,7 @@ operator<=( template< std::size_t N, std::size_t M, typename CharT, typename Traits> +inline bool operator>( fixed_string const& lhs, @@ -2047,6 +2057,7 @@ operator>( template< std::size_t N, std::size_t M, typename CharT, typename Traits> +inline bool operator>=( fixed_string const& lhs, @@ -2056,6 +2067,7 @@ operator>=( } template +inline bool operator==( CharT const* lhs, @@ -2067,6 +2079,7 @@ operator==( } template +inline bool operator==( fixed_string const& lhs, @@ -2078,6 +2091,7 @@ operator==( } template +inline bool operator!=( CharT const* lhs, @@ -2089,6 +2103,7 @@ operator!=( } template +inline bool operator!=( fixed_string const& lhs, @@ -2100,6 +2115,7 @@ operator!=( } template +inline bool operator<( CharT const* lhs, @@ -2111,6 +2127,7 @@ operator<( } template +inline bool operator<( fixed_string const& lhs, @@ -2122,6 +2139,7 @@ operator<( } template +inline bool operator<=( CharT const* lhs, @@ -2133,6 +2151,7 @@ operator<=( } template +inline bool operator<=( fixed_string const& lhs, @@ -2144,6 +2163,7 @@ operator<=( } template +inline bool operator>( CharT const* lhs, @@ -2155,6 +2175,7 @@ operator>( } template +inline bool operator>( fixed_string const& lhs, @@ -2166,6 +2187,7 @@ operator>( } template +inline bool operator>=( CharT const* lhs, @@ -2177,6 +2199,7 @@ operator>=( } template +inline bool operator>=( fixed_string const& lhs, @@ -2193,7 +2216,11 @@ operator>=( // //------------------------------------------------------------------------------ -template +template< + std::size_t N, + typename CharT, + typename Traits> +inline void swap( fixed_string& lhs, @@ -2205,6 +2232,7 @@ swap( template< std::size_t N, std::size_t M, typename CharT, typename Traits> +inline void swap( fixed_string& lhs, @@ -2219,16 +2247,17 @@ swap( // //------------------------------------------------------------------------------ -#ifdef BOOST_FIXED_STRING_STRING_VIEW template +inline std::basic_ostream& operator<<(std::basic_ostream& os, fixed_string const& s) -{ - return os << static_cast< - string_view>(s); +{ + // for the non-trivial CharT + for (const CharT& c : s) + os << c; + return os; } -#endif //------------------------------------------------------------------------------ // @@ -2252,6 +2281,7 @@ template< std::is_integral::value>::type #endif > +inline fixed_string to_fixed_string(Integer x); diff --git a/include/boost/fixed_string/impl/fixed_string.hpp b/include/boost/fixed_string/impl/fixed_string.hpp index 7168476..99198f1 100644 --- a/include/boost/fixed_string/impl/fixed_string.hpp +++ b/include/boost/fixed_string/impl/fixed_string.hpp @@ -787,6 +787,7 @@ assign_char(CharT, std::false_type) -> } template +inline fixed_string to_fixed_string(Integer x) {