Skip to content

Commit 6e0e4fc

Browse files
committed
Introduce suggestions from M-GSL and gcc compiler
- string_noexcept - string_constexpr14 - comparison operator must return bool (gcc -std=c++23) - remove move leftover from experiment
1 parent 0de51d5 commit 6e0e4fc

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

include/nonstd/string.hpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ find_first(
854854
string_nodiscard std::size_t \
855855
find_last( \
856856
std17::basic_string_view<CharT> text \
857-
, SeekT const & seek ) \
857+
, SeekT const & seek ) string_noexcept \
858858
{ \
859859
return text.rfind( seek ); \
860860
}
@@ -939,7 +939,7 @@ find_first(
939939
string_nodiscard bool \
940940
contains( \
941941
std17::basic_string_view<CharT> text \
942-
, SeekT const & seek ) \
942+
, SeekT const & seek ) string_noexcept \
943943
{ \
944944
return text.contains( seek ); \
945945
}
@@ -949,7 +949,7 @@ find_first(
949949
string_nodiscard bool \
950950
contains( \
951951
std17::basic_string_view<CharT> text \
952-
, SeekT const & seek ) \
952+
, SeekT const & seek ) string_noexcept \
953953
{ \
954954
return string::npos != find_first(text, seek); \
955955
}
@@ -1625,7 +1625,7 @@ split( std17::basic_string_view<CharT> text
16251625
lhs = rhs;
16261626
}
16271627

1628-
return std::move( result );
1628+
return result;
16291629
}
16301630

16311631
} // namespace detail
@@ -1679,55 +1679,55 @@ split_right(
16791679

16801680
// defined in namespace nonstd
16811681

1682-
#define string_MK_COMPARE( CharT ) \
1683-
string_nodiscard inline int \
1684-
compare( std17::basic_string_view<CharT> lhs, std17::basic_string_view<CharT> rhs ) \
1685-
{ \
1686-
return lhs.compare( rhs ); \
1682+
#define string_MK_COMPARE( CharT ) \
1683+
string_nodiscard inline string_constexpr14 int \
1684+
compare( std17::basic_string_view<CharT> lhs, std17::basic_string_view<CharT> rhs ) string_noexcept \
1685+
{ \
1686+
return lhs.compare( rhs ); \
16871687
}
16881688

16891689
// defined in namespace nonstd::string::std17
16901690

1691-
#define string_MK_COMPARE_EQ( CharT ) \
1692-
string_nodiscard inline bool \
1691+
#define string_MK_COMPARE_EQ( CharT ) \
1692+
string_nodiscard inline string_constexpr14 bool \
16931693
operator==( basic_string_view<CharT> lhs, basic_string_view<CharT> rhs ) \
1694-
{ \
1695-
return compare( lhs, rhs ) == 0; \
1694+
{ \
1695+
return compare( lhs, rhs ) == 0; \
16961696
}
16971697

1698-
#define string_MK_COMPARE_NE( CharT ) \
1699-
string_nodiscard inline bool \
1698+
#define string_MK_COMPARE_NE( CharT ) \
1699+
string_nodiscard inline string_constexpr14 bool \
17001700
operator!=( basic_string_view<CharT> lhs, basic_string_view<CharT> rhs ) \
1701-
{ \
1702-
return compare( lhs, rhs ) != 0; \
1701+
{ \
1702+
return compare( lhs, rhs ) != 0; \
17031703
}
17041704

1705-
#define string_MK_COMPARE_LT( CharT ) \
1706-
string_nodiscard inline bool \
1705+
#define string_MK_COMPARE_LT( CharT ) \
1706+
string_nodiscard inline string_constexpr14 bool \
17071707
operator<( basic_string_view<CharT> lhs, basic_string_view<CharT> rhs ) \
1708-
{ \
1709-
return compare( lhs, rhs ) < 0; \
1708+
{ \
1709+
return compare( lhs, rhs ) < 0; \
17101710
}
17111711

1712-
#define string_MK_COMPARE_LE( CharT ) \
1713-
string_nodiscard inline bool \
1712+
#define string_MK_COMPARE_LE( CharT ) \
1713+
string_nodiscard inline string_constexpr14 bool \
17141714
operator<=( basic_string_view<CharT> lhs, basic_string_view<CharT> rhs ) \
1715-
{ \
1716-
return compare( lhs, rhs ) <= 0; \
1715+
{ \
1716+
return compare( lhs, rhs ) <= 0; \
17171717
}
17181718

1719-
#define string_MK_COMPARE_GE( CharT ) \
1720-
string_nodiscard inline bool \
1719+
#define string_MK_COMPARE_GE( CharT ) \
1720+
string_nodiscard inline string_constexpr14 bool \
17211721
operator>=( basic_string_view<CharT> lhs, basic_string_view<CharT> rhs ) \
1722-
{ \
1723-
return compare( lhs, rhs ) >= 0; \
1722+
{ \
1723+
return compare( lhs, rhs ) >= 0; \
17241724
}
17251725

1726-
#define string_MK_COMPARE_GT( CharT ) \
1727-
string_nodiscard inline bool \
1726+
#define string_MK_COMPARE_GT( CharT ) \
1727+
string_nodiscard inline string_constexpr14 bool \
17281728
operator>( basic_string_view<CharT> lhs, basic_string_view<CharT> rhs ) \
1729-
{ \
1730-
return compare( lhs, rhs ) > 0; \
1729+
{ \
1730+
return compare( lhs, rhs ) > 0; \
17311731
}
17321732

17331733
//

0 commit comments

Comments
 (0)