Skip to content

Commit

Permalink
Flip the LIBASSERT_STD_VER logic around
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed May 7, 2024
1 parent 4e7cdaa commit 1b5c55f
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions include/libassert/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,17 @@
#error "libassert requires C++17 or newer"
#endif


// Here we assign the current C++ standard number to LIBASSERT_STD_VER if it is not already defined.
// Currently this check assumes that the base version is C++17 and if the version number is greater than
// 202303L then we assume that we are using C++26. Currently, not every compiler has a defined value for C++26
// and to some degree even checking for 202302L is not 100% reliable as some compilers have chosen to not actually define
// the version number for C++23 until they are fully compliant. Still this is a rare case and should be fine here.
// TODO: Once C++26 is fully released we should update this so the else instead uses the proper value.
#ifndef LIBASSERT_STD_VER
#if LIBASSERT_CPLUSPLUS <= 201703L
#define LIBASSERT_STD_VER 17
#elif LIBASSERT_CPLUSPLUS <= 202002L
#define LIBASSERT_STD_VER 20
#elif LIBASSERT_CPLUSPLUS <= 202302L
#define LIBASSERT_STD_VER 23
#else
#define LIBASSERT_STD_VER 26 // If our version number is higher than 202303L assume we are using C++26
#endif // LIBASSERT_CPLUSPLUS
#endif // LIBASSERT_STD_VER
#if LIBASSERT_CPLUSPLUS >= 202302L
#define LIBASSERT_STD_VER 23
#elif LIBASSERT_CPLUSPLUS >= 202002L
#define LIBASSERT_STD_VER 20
#elif LIBASSERT_CPLUSPLUS >= 201703L
#define LIBASSERT_STD_VER 17
#else
#error "Can't happen"
#endif
#endif


///
Expand Down

0 comments on commit 1b5c55f

Please sign in to comment.