forked from boostorg/static_string
Inlined free functions for ODR
This commit is contained in:
@ -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
|
||||
|
@ -19,6 +19,9 @@ namespace boost {
|
||||
namespace fixed_string {
|
||||
namespace detail {
|
||||
|
||||
template<std::size_t, typename, typename>
|
||||
class fixed_string;
|
||||
|
||||
// Because k-ballo said so
|
||||
template<class T>
|
||||
using is_input_iterator =
|
||||
@ -26,6 +29,7 @@ using is_input_iterator =
|
||||
! std::is_integral<T>::value>;
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
inline
|
||||
int
|
||||
lexicographical_compare(
|
||||
CharT const* s1, std::size_t n1,
|
||||
@ -43,6 +47,7 @@ lexicographical_compare(
|
||||
|
||||
#ifdef BOOST_FIXED_STRING_STRING_VIEW
|
||||
template<typename CharT, typename Traits>
|
||||
inline
|
||||
int
|
||||
lexicographical_compare(
|
||||
basic_string_view<CharT, Traits> s1,
|
||||
@ -53,8 +58,20 @@ lexicographical_compare(
|
||||
}
|
||||
#endif
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits >
|
||||
inline
|
||||
int
|
||||
lexicographical_compare(
|
||||
const fixed_string<N, CharT, Traits>& 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<typename CharT, typename Traits>
|
||||
inline
|
||||
int
|
||||
lexicographical_compare(
|
||||
basic_string_view<CharT, Traits> s1,
|
||||
@ -65,6 +82,17 @@ lexicographical_compare(
|
||||
}
|
||||
#endif
|
||||
|
||||
template<std::size_t N, std::size_t M, typename CharT, typename Traits>
|
||||
inline
|
||||
int
|
||||
lexicographical_compare(
|
||||
const fixed_string<N, CharT, Traits>& s1,
|
||||
const fixed_string<M, CharT, Traits>& s2)
|
||||
{
|
||||
return detail::lexicographical_compare<CharT, Traits>(
|
||||
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<typename CharT, class Integer, typename Traits>
|
||||
inline
|
||||
CharT*
|
||||
raw_to_string(
|
||||
CharT* buf, Integer x, std::true_type)
|
||||
@ -103,6 +132,7 @@ raw_to_string(
|
||||
}
|
||||
|
||||
template<typename CharT, class Integer, typename Traits>
|
||||
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<CharT>>
|
||||
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
|
||||
{
|
||||
|
@ -1954,30 +1954,35 @@ private:
|
||||
template<
|
||||
std::size_t N, std::size_t M,
|
||||
typename CharT, typename Traits>
|
||||
inline
|
||||
void
|
||||
operator+(
|
||||
fixed_string<N, CharT, Traits>const& lhs,
|
||||
fixed_string<M, CharT, Traits>const& rhs) = delete;
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
void
|
||||
operator+(
|
||||
CharT const* lhs,
|
||||
fixed_string<N, CharT, Traits>const& rhs) = delete;
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
void
|
||||
operator+(
|
||||
CharT lhs,
|
||||
fixed_string<N, CharT, Traits> const& rhs) = delete;
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
void
|
||||
operator+(
|
||||
fixed_string<N, CharT, Traits> const& lhs,
|
||||
CharT const* rhs) = delete;
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
void
|
||||
operator+(
|
||||
fixed_string<N, CharT, Traits> 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<N, CharT, Traits> 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<N, CharT, Traits> 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<N, CharT, Traits> 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<N, CharT, Traits> 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<N, CharT, Traits> 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<N, CharT, Traits> const& lhs,
|
||||
@ -2056,6 +2067,7 @@ operator>=(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator==(
|
||||
CharT const* lhs,
|
||||
@ -2067,6 +2079,7 @@ operator==(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator==(
|
||||
fixed_string<N, CharT, Traits> const& lhs,
|
||||
@ -2078,6 +2091,7 @@ operator==(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator!=(
|
||||
CharT const* lhs,
|
||||
@ -2089,6 +2103,7 @@ operator!=(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator!=(
|
||||
fixed_string<N, CharT, Traits> const& lhs,
|
||||
@ -2100,6 +2115,7 @@ operator!=(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator<(
|
||||
CharT const* lhs,
|
||||
@ -2111,6 +2127,7 @@ operator<(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator<(
|
||||
fixed_string<N, CharT, Traits> const& lhs,
|
||||
@ -2122,6 +2139,7 @@ operator<(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator<=(
|
||||
CharT const* lhs,
|
||||
@ -2133,6 +2151,7 @@ operator<=(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator<=(
|
||||
fixed_string<N, CharT, Traits> const& lhs,
|
||||
@ -2144,6 +2163,7 @@ operator<=(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator>(
|
||||
CharT const* lhs,
|
||||
@ -2155,6 +2175,7 @@ operator>(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator>(
|
||||
fixed_string<N, CharT, Traits> const& lhs,
|
||||
@ -2166,6 +2187,7 @@ operator>(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator>=(
|
||||
CharT const* lhs,
|
||||
@ -2177,6 +2199,7 @@ operator>=(
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
bool
|
||||
operator>=(
|
||||
fixed_string<N, CharT, Traits> const& lhs,
|
||||
@ -2193,7 +2216,11 @@ operator>=(
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
template<
|
||||
std::size_t N,
|
||||
typename CharT,
|
||||
typename Traits>
|
||||
inline
|
||||
void
|
||||
swap(
|
||||
fixed_string<N, CharT, Traits>& lhs,
|
||||
@ -2205,6 +2232,7 @@ swap(
|
||||
template<
|
||||
std::size_t N, std::size_t M,
|
||||
typename CharT, typename Traits>
|
||||
inline
|
||||
void
|
||||
swap(
|
||||
fixed_string<N, CharT, Traits>& lhs,
|
||||
@ -2219,16 +2247,17 @@ swap(
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifdef BOOST_FIXED_STRING_STRING_VIEW
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
inline
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os,
|
||||
fixed_string<N, CharT, Traits> 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<Integer>::value>::type
|
||||
#endif
|
||||
>
|
||||
inline
|
||||
fixed_string<detail::max_digits(sizeof(Integer))>
|
||||
to_fixed_string(Integer x);
|
||||
|
||||
|
@ -787,6 +787,7 @@ assign_char(CharT, std::false_type) ->
|
||||
}
|
||||
|
||||
template<class Integer, class>
|
||||
inline
|
||||
fixed_string<detail::max_digits(sizeof(Integer))>
|
||||
to_fixed_string(Integer x)
|
||||
{
|
||||
|
Reference in New Issue
Block a user