Skip to content

Commit

Permalink
Added SCN_CONSTEXPRIF
Browse files Browse the repository at this point in the history
  • Loading branch information
matbech authored and eliaskosunen committed Nov 2, 2023
1 parent 121c2d4 commit d73302b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions include/scn/detail/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@
#define SCN_CONSTEXPR14 inline
#endif


// Detect constexpr if
#if (__cplusplus >= SCN_STD_17) || \
((SCN_MSVC >= SCN_COMPILER(19, 11, 0) && SCN_MSVC_LANG >= SCN_STD_17))
#define SCN_CONSTEXPRIF constexpr
#else
#define SCN_CONSTEXPRIF
#endif

// Detect string_view
#if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201603 && \
SCN_STD >= SCN_STD_17
Expand Down
8 changes: 4 additions & 4 deletions src/locale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace scn {
span<const char_type> ch) const
{
const auto& locale = to_locale(*this);
if constexpr (sizeof(CharT) == 1) {
if SCN_CONSTEXPRIF (sizeof(CharT) == 1) {
SCN_EXPECT(ch.size() >= 1);
code_point cp{};
auto it = parse_code_point(ch.begin(), ch.end(), cp);
Expand All @@ -271,7 +271,7 @@ namespace scn {
span<const char_type> ch) const
{
const auto& locale = to_locale(*this);
if constexpr (sizeof(CharT) == 1) {
if SCN_CONSTEXPRIF (sizeof(CharT) == 1) {
SCN_EXPECT(ch.size() >= 1);
code_point cp{};
auto it = parse_code_point(ch.begin(), ch.end(), cp);
Expand All @@ -298,7 +298,7 @@ namespace scn {
const \
{ \
const auto& locale = to_locale(*this); \
if constexpr (sizeof(CharT) == 1) { \
if SCN_CONSTEXPRIF (sizeof(CharT) == 1) { \
SCN_EXPECT(ch.size() >= 1); \
code_point cp{}; \
auto it = parse_code_point(ch.begin(), ch.end(), cp); \
Expand Down Expand Up @@ -348,7 +348,7 @@ namespace scn {
span<const char_type> ch) const
{
const auto& locale = to_locale(*this);
if constexpr (sizeof(CharT) == 1) {
if SCN_CONSTEXPRIF (sizeof(CharT) == 1) {
SCN_EXPECT(ch.size() >= 1);
code_point cp{};
auto it = parse_code_point(ch.begin(), ch.end(), cp);
Expand Down

0 comments on commit d73302b

Please sign in to comment.