Skip to content

Added constexpr if #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 if constexpr
#if (defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606) || \
((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 (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 (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 (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 (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