Skip to content

Commit 4292b73

Browse files
committed
Use std::string_view::npos or std::string::npos for nonstd::string::npos
1 parent b4053b8 commit 4292b73

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

include/nonstd/string.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,15 @@ namespace string {
281281

282282
// npos
283283

284-
#if string_CPP17_OR_GREATER
285-
static string_constexpr std::size_t npos = std::size_t(-1);
284+
#if string_HAVE_STRING_VIEW
285+
static string_constexpr std::size_t npos = std::string_view::npos;
286+
#elif string_CPP17_OR_GREATER
287+
static string_constexpr std::size_t npos = std::string::npos;
286288
#elif string_CPP11_OR_GREATER
287-
enum : std::size_t { npos = std::size_t(-1) };
289+
enum : std::size_t { npos = std::string::npos };
288290
#else
289-
enum { npos = std::size_t(-1) };
290-
#endif
291+
enum { npos = std::string::npos };
292+
#endif // string_HAVE_STRING_VIEW
291293

292294
namespace detail {
293295

0 commit comments

Comments
 (0)