Skip to content

Commit e0199ac

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

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

include/nonstd/string.hpp

Lines changed: 9 additions & 7 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);
286-
#elif string_CPP11_OR_GREATER
287-
enum : std::size_t { npos = std::size_t(-1) };
288-
#else
289-
enum { npos = std::size_t(-1) };
290-
#endif
284+
#if string_HAVE_STRING_VIEW
285+
static string_constexpr std::size_t npos = std::basic_string_view<char>::npos;
286+
# elif string_CPP17_OR_GREATER
287+
static string_constexpr std::size_t npos = std::string::npos;
288+
# elif string_CPP11_OR_GREATER
289+
enum : std::size_t { npos = std::string::npos };
290+
# else
291+
enum { npos = std::string::npos };
292+
#endif // string_HAVE_STRING_VIEW
291293

292294
namespace detail {
293295

0 commit comments

Comments
 (0)