Back to requiring a string_view implementation

This commit is contained in:
Krystian Stasiowski
2019-10-28 23:48:11 -04:00
parent 5c81f47f7f
commit 1a65754a1f
4 changed files with 13 additions and 109 deletions

View File

@ -13,18 +13,16 @@
// Are we dependent on Boost? // Are we dependent on Boost?
#define BOOST_FIXED_STRING_USE_BOOST #define BOOST_FIXED_STRING_USE_BOOST
// C++ version // Can we have deduction guides?
#if __cplusplus >= 201703L #ifdef __cpp_deduction_guides
#define BOOST_FIXED_STRING_CPP17 #define BOOST_FIXED_STRING_USE_DEDUCT
#elif __cplusplus >= 201402L
#define BOOST_FIXED_STRING_CPP14
#else
#define BOOST_FIXED_STRING_CPP11
#endif #endif
// See if we can use `string_view` // Can we use [[nodiscard]]?
#if defined(BOOST_FIXED_STRING_CPP17) || defined(BOOST_FIXED_STRING_USE_BOOST) #if __has_attribute(nodiscard)
#define BOOST_FIXED_STRING_STRING_VIEW #define BOOST_FIXED_STRING_NODISCARD [[nodiscard]]
#else
#define BOOST_FIXED_STRING_NODISCARD
#endif #endif
#ifdef BOOST_FIXED_STRING_USE_BOOST #ifdef BOOST_FIXED_STRING_USE_BOOST
@ -34,47 +32,32 @@
#include <boost/throw_exception.hpp> #include <boost/throw_exception.hpp>
#else #else
#include <cassert> #include <cassert>
#ifdef BOOST_FIXED_STRING_CPP17
#include <string_view> #include <string_view>
#endif #endif
#endif
// Boost and non-Boost versions of utilities // Boost and non-Boost versions of utilities
#ifdef BOOST_FIXED_STRING_USE_BOOST #ifdef BOOST_FIXED_STRING_USE_BOOST
#define BOOST_FIXED_STRING_THROW(ex) BOOST_THROW_EXCEPTION(ex) #define BOOST_FIXED_STRING_THROW(ex) BOOST_THROW_EXCEPTION(ex)
#define BOOST_FIXED_STRING_STATIC_ASSERT(cond, msg) BOOST_STATIC_ASSERT_MSG(cond, msg) #define BOOST_FIXED_STRING_STATIC_ASSERT(cond, msg) BOOST_STATIC_ASSERT_MSG(cond, msg)
#define BOOST_FIXED_STRING_ASSERT(cond) BOOST_ASSERT(cond) #define BOOST_FIXED_STRING_ASSERT(cond) BOOST_ASSERT(cond)
#ifdef BOOST_NODISCARD
#define BOOST_FIXED_STRING_NODISCARD BOOST_NODISCARD
#else
#define BOOST_FIXED_STRING_NODISCARD
#endif
#else #else
#define BOOST_FIXED_STRING_THROW(ex) throw ex #define BOOST_FIXED_STRING_THROW(ex) throw ex
#define BOOST_FIXED_STRING_STATIC_ASSERT(cond, msg) static_assert(cond, msg) #define BOOST_FIXED_STRING_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
#define BOOST_FIXED_STRING_ASSERT(cond) assert(cond) #define BOOST_FIXED_STRING_ASSERT(cond) assert(cond)
#ifdef BOOST_FIXED_STRING_CPP17
#define BOOST_FIXED_STRING_NODISCARD [[nodiscard]]
#else
#define BOOST_FIXED_STRING_NODISCARD
#endif
#endif #endif
namespace boost { namespace boost {
namespace fixed_string { namespace fixed_string {
/// The type of `string_view` used by the library /// The type of `string_view` used by the library
#ifdef BOOST_FIXED_STRING_STRING_VIEW
using string_view = using string_view =
#ifdef BOOST_FIXED_STRING_USE_BOOST #ifdef BOOST_FIXED_STRING_USE_BOOST
boost::string_view; boost::string_view;
#else #else
std::string_view; std::string_view;
#endif #endif
#endif
/// The type of `basic_string_view` used by the library /// The type of `basic_string_view` used by the library
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename CharT, typename Traits> template<typename CharT, typename Traits>
using basic_string_view = using basic_string_view =
#ifdef BOOST_FIXED_STRING_USE_BOOST #ifdef BOOST_FIXED_STRING_USE_BOOST
@ -82,7 +65,6 @@ using basic_string_view =
#else #else
std::basic_string_view<CharT, Traits>; std::basic_string_view<CharT, Traits>;
#endif #endif
#endif
} // fixed_string } // fixed_string
} // boost } // boost

View File

@ -44,8 +44,6 @@ lexicographical_compare(
return Traits::compare(s1, s2, n1); return Traits::compare(s1, s2, n1);
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename CharT, typename Traits> template<typename CharT, typename Traits>
inline inline
int int
@ -56,7 +54,6 @@ lexicographical_compare(
return detail::lexicographical_compare< return detail::lexicographical_compare<
CharT, Traits>(s1.data(), s1.size(), s2, n2); CharT, Traits>(s1.data(), s1.size(), s2, n2);
} }
#endif
template<std::size_t N, typename CharT, typename Traits > template<std::size_t N, typename CharT, typename Traits >
inline inline
@ -69,7 +66,6 @@ lexicographical_compare(
CharT, Traits>(s1.data(), s1.size(), s2, n2); CharT, Traits>(s1.data(), s1.size(), s2, n2);
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename CharT, typename Traits> template<typename CharT, typename Traits>
inline inline
int int
@ -80,7 +76,6 @@ lexicographical_compare(
return detail::lexicographical_compare<CharT, Traits>( return detail::lexicographical_compare<CharT, Traits>(
s1.data(), s1.size(), s2.data(), s2.size()); s1.data(), s1.size(), s2.data(), s2.size());
} }
#endif
template<std::size_t N, std::size_t M, typename CharT, typename Traits> template<std::size_t N, std::size_t M, typename CharT, typename Traits>
inline inline

View File

@ -77,10 +77,8 @@ public:
std::reverse_iterator<const_iterator>; std::reverse_iterator<const_iterator>;
/// The type of `string_view` returned by the interface /// The type of `string_view` returned by the interface
#ifdef BOOST_FIXED_STRING_STRING_VIEW
using string_view_type = using string_view_type =
string_view; string_view;
#endif
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// //
@ -160,11 +158,9 @@ public:
/// Construct from a `string_view` /// Construct from a `string_view`
#ifdef BOOST_FIXED_STRING_STRING_VIEW
explicit explicit
fixed_string( fixed_string(
string_view_type sv); string_view_type sv);
#endif
/** Construct from any object convertible to `string_view_type`. /** Construct from any object convertible to `string_view_type`.
@ -172,7 +168,6 @@ public:
obtained by converting `t` to `string_view_type`, obtained by converting `t` to `string_view_type`,
and used to construct the string. and used to construct the string.
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T template<typename T
#ifndef GENERATING_DOCUMENTATION #ifndef GENERATING_DOCUMENTATION
, class = typename std::enable_if< , class = typename std::enable_if<
@ -183,7 +178,6 @@ public:
T const& t, T const& t,
size_type pos, size_type pos,
size_type n); size_type n);
#endif
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// //
@ -244,14 +238,12 @@ public:
} }
/// Assign from `string_view_type`. /// Assign from `string_view_type`.
#ifdef BOOST_FIXED_STRING_STRING_VIEW
fixed_string& fixed_string&
operator=( operator=(
string_view_type sv) string_view_type sv)
{ {
return assign(sv); return assign(sv);
} }
#endif
/** Replace the contents with `count` copies of character `ch` /** Replace the contents with `count` copies of character `ch`
@ -354,7 +346,6 @@ public:
@throw std::length_error if `string_view_type{t}.size() > max_size()` @throw std::length_error if `string_view_type{t}.size() > max_size()`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
fixed_string& fixed_string&
@ -369,7 +360,6 @@ public:
string_view_type ss{t}; string_view_type ss{t};
return assign(ss.data(), ss.size()); return assign(ss.data(), ss.size());
} }
#endif
/** Replace the contents with a copy of the characters from `string_view_type{t}.substr(pos, count)` /** Replace the contents with a copy of the characters from `string_view_type{t}.substr(pos, count)`
@ -381,7 +371,6 @@ public:
@throw std::length_error if `string_view_type{t}.substr(pos, count).size() > max_size()` @throw std::length_error if `string_view_type{t}.substr(pos, count).size() > max_size()`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
fixed_string& fixed_string&
@ -398,7 +387,6 @@ public:
{ {
return assign(string_view_type{t}.substr(pos, count)); return assign(string_view_type{t}.substr(pos, count));
} }
#endif
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// //
@ -502,13 +490,11 @@ public:
} }
/// Convert a static string to a `string_view_type` /// Convert a static string to a `string_view_type`
#ifdef BOOST_FIXED_STRING_STRING_VIEW
operator string_view_type() const noexcept operator string_view_type() const noexcept
{ {
return basic_string_view< return basic_string_view<
CharT, Traits>{data(), size()}; CharT, Traits>{data(), size()};
} }
#endif
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// //
@ -724,7 +710,6 @@ public:
@throw std::length_error if `size() + sv.size() > max_size()` @throw std::length_error if `size() + sv.size() > max_size()`
@return `*this` @return `*this`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
fixed_string& fixed_string&
insert( insert(
size_type index, size_type index,
@ -732,7 +717,6 @@ public:
{ {
return insert(index, sv.data(), sv.size()); return insert(index, sv.data(), sv.size());
} }
#endif
/** Inserts the string `sv.substr(index_str, count)` at the position `index` /** Inserts the string `sv.substr(index_str, count)` at the position `index`
@ -742,7 +726,6 @@ public:
@throw std::length_error if `size() + sv.substr(index_str, count).size() > max_size()` @throw std::length_error if `size() + sv.substr(index_str, count).size() > max_size()`
@return `*this` @return `*this`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
fixed_string& fixed_string&
insert( insert(
size_type index, size_type index,
@ -752,7 +735,6 @@ public:
{ {
return insert(index, sv.substr(index_str, count)); return insert(index, sv.substr(index_str, count));
} }
#endif
/** Inserts character `ch` before the character (if any) pointed by `pos` /** Inserts character `ch` before the character (if any) pointed by `pos`
@ -829,7 +811,6 @@ public:
@throw std::length_error if `size() + string_view{t}.substr(index_str, count).size() > max_size()` @throw std::length_error if `size() + string_view{t}.substr(index_str, count).size() > max_size()`
@return `*this` @return `*this`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
fixed_string& fixed_string&
@ -844,7 +825,6 @@ public:
insert( insert(
size_type index, size_type index,
T const& t); T const& t);
#endif
/** Inserts elements from `string_view{t}.substr(index_str, count)` at the position `index` /** Inserts elements from `string_view{t}.substr(index_str, count)` at the position `index`
@ -857,7 +837,6 @@ public:
@throw std::length_error if `size() + string_view{t}.substr(index_str, count).size() > max_size()` @throw std::length_error if `size() + string_view{t}.substr(index_str, count).size() > max_size()`
@return `*this` @return `*this`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
fixed_string& fixed_string&
@ -872,7 +851,6 @@ public:
T const& t, T const& t,
size_type index_str, size_type index_str,
size_type count = npos); size_type count = npos);
#endif
/** Removes `min(count, size() - index)` characters starting at `index` /** Removes `min(count, size() - index)` characters starting at `index`
@ -942,14 +920,12 @@ public:
@throw std::length_error if `size() + sv.size() > max_size()` @throw std::length_error if `size() + sv.size() > max_size()`
@return `*this` @return `*this`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
fixed_string& fixed_string&
append( append(
string_view_type sv) string_view_type sv)
{ {
return append(sv.data(), sv.size()); return append(sv.data(), sv.size());
} }
#endif
/** Appends the contents of `sv.substr(pos, count)` /** Appends the contents of `sv.substr(pos, count)`
@ -959,7 +935,6 @@ public:
@throw std::length_error if `size() + sv.substr(pos, count).size() > max_size()` @throw std::length_error if `size() + sv.substr(pos, count).size() > max_size()`
@return `*this` @return `*this`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
fixed_string& fixed_string&
append( append(
string_view_type sv, string_view_type sv,
@ -968,7 +943,6 @@ public:
{ {
return append(sv.substr(pos, count)); return append(sv.substr(pos, count));
} }
#endif
/** Appends characters in the range `(s, s + count)` /** Appends characters in the range `(s, s + count)`
@ -1047,7 +1021,6 @@ public:
@throw std::length_error if `size() + string_view{t} > max_size()` @throw std::length_error if `size() + string_view{t} > max_size()`
@return `*this` @return `*this`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
fixed_string& fixed_string&
@ -1064,7 +1037,6 @@ public:
{ {
return append(string_view{t}); return append(string_view{t});
} }
#endif
/** Appends characters from `string_view{t}.substr{pos, count}` /** Appends characters from `string_view{t}.substr{pos, count}`
@ -1077,7 +1049,6 @@ public:
@throw std::length_error if `size() + string_view{t}.substr(pos, count).size() > max_size()` @throw std::length_error if `size() + string_view{t}.substr(pos, count).size() > max_size()`
@return `*this` @return `*this`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
fixed_string& fixed_string&
@ -1096,7 +1067,6 @@ public:
{ {
return append(string_view{t}.substr(pos, count)); return append(string_view{t}.substr(pos, count));
} }
#endif
template<std::size_t M> template<std::size_t M>
fixed_string& fixed_string&
@ -1156,7 +1126,6 @@ public:
@throw std::length_error if `string_view_type{t}.size() > max_size()` @throw std::length_error if `string_view_type{t}.size() > max_size()`
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
fixed_string& fixed_string&
@ -1171,7 +1140,6 @@ public:
{ {
return append(t); return append(t);
} }
#endif
template<std::size_t M> template<std::size_t M>
int int
@ -1235,7 +1203,6 @@ public:
substr(pos1, count1), s, count2); substr(pos1, count1), s, count2);
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW
int int
compare( compare(
string_view_type s) const string_view_type s) const
@ -1244,9 +1211,6 @@ public:
&s_[0], n_, s.data(), s.size()); &s_[0], n_, s.data(), s.size());
} }
#endif
#ifdef BOOST_FIXED_STRING_STRING_VIEW
int int
compare( compare(
size_type pos1, size_type pos1,
@ -1256,9 +1220,7 @@ public:
return detail::lexicographical_compare<CharT, Traits>( return detail::lexicographical_compare<CharT, Traits>(
substr(pos1, count1), s); substr(pos1, count1), s);
} }
#endif
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
int int
@ -1278,9 +1240,8 @@ public:
return compare(pos1, count1, return compare(pos1, count1,
string_view_type(t).substr(pos2, count2)); string_view_type(t).substr(pos2, count2));
} }
#endif
fixed_string string_view_type
substr( substr(
size_type pos = 0, size_type pos = 0,
size_type count = npos) const; size_type count = npos) const;
@ -1344,7 +1305,6 @@ public:
return replace(pos1, n1, str.substr(pos2, n2)); return replace(pos1, n1, str.substr(pos2, n2));
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
fixed_string& fixed_string&
@ -1362,12 +1322,9 @@ public:
string_view_type sv = t; string_view_type sv = t;
return replace(pos1, n1, sv.data(), sv.size()); return replace(pos1, n1, sv.data(), sv.size());
} }
#endif
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATI #if GENERATING_DOCUMENTATION
NG_DOCUMENTATION
fixed_string& fixed_string&
#else #else
typename std::enable_if< typename std::enable_if<
@ -1385,7 +1342,6 @@ public:
string_view_type sv = t; string_view_type sv = t;
return replace(pos1, n1, sv.substr(pos2, n2)); return replace(pos1, n1, sv.substr(pos2, n2));
} }
#endif
fixed_string& fixed_string&
replace( replace(
@ -1419,7 +1375,6 @@ public:
return replace(i1, i2, str.data(), str.size()); return replace(i1, i2, str.data(), str.size());
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename T> template<typename T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
fixed_string& fixed_string&
@ -1437,7 +1392,6 @@ public:
string_view_type sv = t; string_view_type sv = t;
return replace(i1 - begin(), i2 - i1, sv.data(), sv.size()); return replace(i1 - begin(), i2 - i1, sv.data(), sv.size());
} }
#endif
fixed_string& fixed_string&
replace( replace(
@ -1506,7 +1460,6 @@ public:
`T` is convertible to `string_view` and `T` is not `T` is convertible to `string_view` and `T` is not
convertible to `CharT const*`. convertible to `CharT const*`.
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<class T> template<class T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
size_type size_type
@ -1523,7 +1476,6 @@ public:
string_view_type sv = t; string_view_type sv = t;
return find(sv.data(), pos, sv.size()); return find(sv.data(), pos, sv.size());
} }
#endif
template<std::size_t N> template<std::size_t N>
size_type size_type
@ -1571,7 +1523,6 @@ public:
`T` is convertible to `string_view` and `T` is not `T` is convertible to `string_view` and `T` is not
convertible to `CharT const*`. convertible to `CharT const*`.
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<class T> template<class T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
size_type size_type
@ -1588,7 +1539,6 @@ public:
string_view_type sv = t; string_view_type sv = t;
return rfind(sv.data(), pos, sv.size()); return rfind(sv.data(), pos, sv.size());
} }
#endif
template<std::size_t N> template<std::size_t N>
size_type size_type
@ -1635,7 +1585,6 @@ public:
`T` is convertible to `string_view` and `T` is not `T` is convertible to `string_view` and `T` is not
convertible to `CharT const*`. convertible to `CharT const*`.
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<class T> template<class T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
size_type size_type
@ -1652,7 +1601,6 @@ public:
string_view_type sv = t; string_view_type sv = t;
return find_first_of(sv.data(), pos, sv.size()); return find_first_of(sv.data(), pos, sv.size());
} }
#endif
template<std::size_t N> template<std::size_t N>
size_type size_type
@ -1699,7 +1647,6 @@ public:
`T` is convertible to `string_view` and `T` is not `T` is convertible to `string_view` and `T` is not
convertible to `CharT const*`. convertible to `CharT const*`.
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<class T> template<class T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
size_type size_type
@ -1716,7 +1663,6 @@ public:
string_view_type sv = t; string_view_type sv = t;
return find_last_of(sv.data(), pos, sv.size()); return find_last_of(sv.data(), pos, sv.size());
} }
#endif
template<std::size_t N> template<std::size_t N>
size_type size_type
@ -1763,7 +1709,6 @@ public:
`T` is convertible to `string_view` and `T` is not `T` is convertible to `string_view` and `T` is not
convertible to `CharT const*`. convertible to `CharT const*`.
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<class T> template<class T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
size_type size_type
@ -1780,7 +1725,6 @@ public:
string_view_type sv = t; string_view_type sv = t;
return find_first_not_of(sv.data(), pos, sv.size()); return find_first_not_of(sv.data(), pos, sv.size());
} }
#endif
template<std::size_t N> template<std::size_t N>
size_type size_type
@ -1827,7 +1771,6 @@ public:
`T` is convertible to `string_view` and `T` is not `T` is convertible to `string_view` and `T` is not
convertible to `CharT const*`. convertible to `CharT const*`.
*/ */
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<class T> template<class T>
#if GENERATING_DOCUMENTATION #if GENERATING_DOCUMENTATION
size_type size_type
@ -1844,7 +1787,6 @@ public:
string_view_type sv = t; string_view_type sv = t;
return find_last_not_of(sv.data(), pos, sv.size()); return find_last_not_of(sv.data(), pos, sv.size());
} }
#endif
template<size_t N> template<size_t N>
size_type size_type
@ -1886,14 +1828,12 @@ public:
return find_last_not_of(&c, pos, 1); return find_last_not_of(&c, pos, 1);
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW
bool bool
starts_with( starts_with(
string_view_type s) const noexcept string_view_type s) const noexcept
{ {
return starts_with(s.data()); return starts_with(s.data());
} }
#endif
bool bool
starts_with( starts_with(
@ -1910,14 +1850,12 @@ public:
return n_ >= len && !Traits::compare(s_, s, len); return n_ >= len && !Traits::compare(s_, s, len);
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW
bool bool
ends_with( ends_with(
string_view_type s) const noexcept string_view_type s) const noexcept
{ {
return ends_with(s.data()); return ends_with(s.data());
} }
#endif
bool bool
ends_with( ends_with(
@ -2253,10 +2191,7 @@ std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os, operator<<(std::basic_ostream<CharT, Traits>& os,
fixed_string<N, CharT, Traits> const& s) fixed_string<N, CharT, Traits> const& s)
{ {
// for the non-trivial CharT return os << string_view(s);
for (const CharT& c : s)
os << c;
return os;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -2291,7 +2226,7 @@ to_fixed_string(Integer x);
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#ifdef BOOST_FIXED_STRING_CPP17 #ifdef BOOST_FIXED_STRING_USE_DEDUCT
template<std::size_t N, typename CharT> template<std::size_t N, typename CharT>
fixed_string(CharT(&)[N]) -> fixed_string(CharT(&)[N]) ->
fixed_string<N, CharT, std::char_traits<CharT>>; fixed_string<N, CharT, std::char_traits<CharT>>;

View File

@ -113,16 +113,13 @@ fixed_string(std::initializer_list<CharT> init)
assign(init.begin(), init.end()); assign(init.begin(), init.end());
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<std::size_t N, typename CharT, typename Traits> template<std::size_t N, typename CharT, typename Traits>
fixed_string<N, CharT, Traits>:: fixed_string<N, CharT, Traits>::
fixed_string(string_view_type sv) fixed_string(string_view_type sv)
{ {
assign(sv); assign(sv);
} }
#endif
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<std::size_t N, typename CharT, typename Traits> template<std::size_t N, typename CharT, typename Traits>
template<class T, class> template<class T, class>
fixed_string<N, CharT, Traits>:: fixed_string<N, CharT, Traits>::
@ -130,7 +127,6 @@ fixed_string(T const& t, size_type pos, size_type n)
{ {
assign(t, pos, n); assign(t, pos, n);
} }
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// //
@ -393,7 +389,6 @@ insert(
return begin() + index; return begin() + index;
} }
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<std::size_t N, typename CharT, typename Traits> template<std::size_t N, typename CharT, typename Traits>
template<class T> template<class T>
auto auto
@ -410,9 +405,7 @@ insert(
{ {
return insert(index, t, 0, npos); return insert(index, t, 0, npos);
} }
#endif
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<std::size_t N, typename CharT, typename Traits> template<std::size_t N, typename CharT, typename Traits>
template<class T> template<class T>
auto auto
@ -433,7 +426,6 @@ insert(
string_view_type(t).substr(index_str, count); string_view_type(t).substr(index_str, count);
return insert(index, s.data(), s.size()); return insert(index, s.data(), s.size());
} }
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -515,7 +507,7 @@ template<std::size_t N, typename CharT, typename Traits>
auto auto
fixed_string<N, CharT, Traits>:: fixed_string<N, CharT, Traits>::
substr(size_type pos, size_type count) const -> substr(size_type pos, size_type count) const ->
fixed_string<N, CharT, Traits> string_view
{ {
if(pos > size()) if(pos > size())
BOOST_FIXED_STRING_THROW(std::out_of_range{ BOOST_FIXED_STRING_THROW(std::out_of_range{