TRLC Platform Library  1.0.0
Header-only C++ library for compile-time platform detection and abstraction
cpp_standard.hpp File Reference

C++ standard version and feature detection for trlc-platform. More...

Go to the source code of this file.

Classes

struct  trlc::platform::CppStandardInfo
 C++ standard information structure. More...
 

Namespaces

 trlc
 
 trlc::platform
 
 trlc::platform::detail
 

Macros

#define TRLC_CPP17   1
 
#define TRLC_CPP20   1
 
#define TRLC_CPP23   0
 
#define TRLC_CPP26   0
 
#define TRLC_CPP_VERSION   __cplusplus
 
#define TRLC_HAS_STRUCTURED_BINDINGS   TRLC_CPP17
 
#define TRLC_HAS_IF_CONSTEXPR   TRLC_CPP17
 
#define TRLC_HAS_CONCEPTS   TRLC_CPP20
 
#define TRLC_HAS_COROUTINES   TRLC_CPP20
 
#define TRLC_HAS_MODULES   0
 
#define TRLC_HAS_RANGES   TRLC_CPP20
 
#define TRLC_HAS_FOLD_EXPRESSIONS   TRLC_CPP17
 
#define TRLC_HAS_CONSTEVAL   TRLC_CPP20
 
#define TRLC_IF_CPP17(code)   code
 
#define TRLC_IF_CPP20(code)   code
 
#define TRLC_IF_CPP23(code)
 
#define TRLC_CONSTEXPR_IF(...)   if constexpr (__VA_ARGS__)
 
#define TRLC_IF_STRUCTURED_BINDINGS(code)   code
 
#define TRLC_IF_CONCEPTS(code)   code
 
#define TRLC_IF_COROUTINES(code)   code
 
#define TRLC_IF_RANGES(code)   code
 
#define TRLC_HAS_STRING_VIEW   1
 
#define TRLC_HAS_OPTIONAL   1
 
#define TRLC_HAS_VARIANT   1
 
#define TRLC_HAS_ANY   1
 
#define TRLC_HAS_FILESYSTEM   1
 
#define TRLC_HAS_SPAN   1
 
#define TRLC_HAS_FORMAT   1
 
#define TRLC_HAS_CONCEPTS_LIB   1
 
#define TRLC_HAS_CHRONO_CALENDAR   1
 

Enumerations

enum class  trlc::platform::CppStandard : long {
  trlc::platform::cpp_pre_17 = 0 , trlc::platform::cpp_17 = 201703L , trlc::platform::cpp_20 = 202002L , trlc::platform::cpp_23 = 202302L ,
  trlc::platform::cpp_26 = 202600L , trlc::platform::cpp_unknown = -1
}
 C++ standard enumeration. More...
 

Functions

static CppStandard trlc::platform::detail::detectCppStandard ()
 Detects C++ standard using __cplusplus macro. More...
 
static long trlc::platform::detail::getCppVersionMacroValue ()
 Gets the __cplusplus macro value. More...
 
static const char * trlc::platform::detail::getCppStandardName ()
 Gets human-readable standard name. More...
 
static CppStandard trlc::platform::getCppStandard ()
 Gets the current C++ standard version. More...
 
static CppStandardInfo trlc::platform::getCppStandardInfo ()
 Gets comprehensive C++ standard information. More...
 
static long trlc::platform::getCppVersionMacro ()
 Gets the __cplusplus macro value. More...
 
static bool trlc::platform::hasStructuredBindings ()
 Checks if structured bindings are supported (C++17) More...
 
static bool trlc::platform::hasIfConstexpr ()
 Checks if if constexpr is supported (C++17) More...
 
static bool trlc::platform::hasConcepts ()
 Checks if concepts are supported (C++20) More...
 
static bool trlc::platform::hasCoroutines ()
 Checks if coroutines are supported (C++20) More...
 
static bool trlc::platform::hasModules ()
 Checks if modules are supported (C++20) More...
 
static bool trlc::platform::hasRanges ()
 Checks if ranges library is supported (C++20) More...
 
static bool trlc::platform::hasFoldExpressions ()
 Checks if fold expressions are supported (C++17) More...
 
static bool trlc::platform::hasInlineVariables ()
 Checks if inline variables are supported (C++17) More...
 
static bool trlc::platform::hasConsteval ()
 Checks if consteval is supported (C++20) More...
 
static bool trlc::platform::hasConstinit ()
 Checks if constinit is supported (C++20) More...
 
static bool trlc::platform::hasDesignatedInitializers ()
 Checks if designated initializers are supported (C++20) More...
 
static bool trlc::platform::hasThreeWayComparison ()
 Checks if three-way comparison (spaceship operator) is supported (C++20) More...
 
static bool trlc::platform::isCpp17OrLater ()
 Checks if the current C++ standard is at least C++17. More...
 
static bool trlc::platform::isCpp20OrLater ()
 Checks if the current C++ standard is at least C++20. More...
 
static bool trlc::platform::isCpp23OrLater ()
 Checks if the current C++ standard is at least C++23. More...
 
static bool trlc::platform::isExactlyCpp17 ()
 Checks if the current C++ standard is exactly C++17. More...
 
static bool trlc::platform::isExactlyCpp20 ()
 Checks if the current C++ standard is exactly C++20. More...
 
static bool trlc::platform::isExactlyCpp23 ()
 Checks if the current C++ standard is exactly C++23. More...
 

Detailed Description

C++ standard version and feature detection for trlc-platform.

This header provides compile-time detection of the active C++ standard version and availability of standard-specific language features. All functions are constexpr and evaluate at compile time for zero runtime overhead.

Author
trlc-platform
Version
1.0.0

Definition in file cpp_standard.hpp.

Macro Definition Documentation

◆ TRLC_CONSTEXPR_IF

#define TRLC_CONSTEXPR_IF (   ...)    if constexpr (__VA_ARGS__)

Definition at line 535 of file cpp_standard.hpp.

◆ TRLC_CPP17

#define TRLC_CPP17   1

Definition at line 397 of file cpp_standard.hpp.

◆ TRLC_CPP20

#define TRLC_CPP20   1

Definition at line 403 of file cpp_standard.hpp.

◆ TRLC_CPP23

#define TRLC_CPP23   0

Definition at line 411 of file cpp_standard.hpp.

◆ TRLC_CPP26

#define TRLC_CPP26   0

Definition at line 417 of file cpp_standard.hpp.

◆ TRLC_CPP_VERSION

#define TRLC_CPP_VERSION   __cplusplus

Definition at line 422 of file cpp_standard.hpp.

◆ TRLC_HAS_ANY

#define TRLC_HAS_ANY   1

Definition at line 570 of file cpp_standard.hpp.

◆ TRLC_HAS_CHRONO_CALENDAR

#define TRLC_HAS_CHRONO_CALENDAR   1

Definition at line 584 of file cpp_standard.hpp.

◆ TRLC_HAS_CONCEPTS

#define TRLC_HAS_CONCEPTS   TRLC_CPP20

Definition at line 455 of file cpp_standard.hpp.

◆ TRLC_HAS_CONCEPTS_LIB

#define TRLC_HAS_CONCEPTS_LIB   1

Definition at line 583 of file cpp_standard.hpp.

◆ TRLC_HAS_CONSTEVAL

#define TRLC_HAS_CONSTEVAL   TRLC_CPP20

Definition at line 511 of file cpp_standard.hpp.

◆ TRLC_HAS_COROUTINES

#define TRLC_HAS_COROUTINES   TRLC_CPP20

Definition at line 471 of file cpp_standard.hpp.

◆ TRLC_HAS_FILESYSTEM

#define TRLC_HAS_FILESYSTEM   1

Definition at line 571 of file cpp_standard.hpp.

◆ TRLC_HAS_FOLD_EXPRESSIONS

#define TRLC_HAS_FOLD_EXPRESSIONS   TRLC_CPP17

Definition at line 501 of file cpp_standard.hpp.

◆ TRLC_HAS_FORMAT

#define TRLC_HAS_FORMAT   1

Definition at line 582 of file cpp_standard.hpp.

◆ TRLC_HAS_IF_CONSTEXPR

#define TRLC_HAS_IF_CONSTEXPR   TRLC_CPP17

Definition at line 445 of file cpp_standard.hpp.

◆ TRLC_HAS_MODULES

#define TRLC_HAS_MODULES   0

Definition at line 481 of file cpp_standard.hpp.

◆ TRLC_HAS_OPTIONAL

#define TRLC_HAS_OPTIONAL   1

Definition at line 568 of file cpp_standard.hpp.

◆ TRLC_HAS_RANGES

#define TRLC_HAS_RANGES   TRLC_CPP20

Definition at line 491 of file cpp_standard.hpp.

◆ TRLC_HAS_SPAN

#define TRLC_HAS_SPAN   1

Definition at line 581 of file cpp_standard.hpp.

◆ TRLC_HAS_STRING_VIEW

#define TRLC_HAS_STRING_VIEW   1

Definition at line 567 of file cpp_standard.hpp.

◆ TRLC_HAS_STRUCTURED_BINDINGS

#define TRLC_HAS_STRUCTURED_BINDINGS   TRLC_CPP17

Definition at line 435 of file cpp_standard.hpp.

◆ TRLC_HAS_VARIANT

#define TRLC_HAS_VARIANT   1

Definition at line 569 of file cpp_standard.hpp.

◆ TRLC_IF_CONCEPTS

#define TRLC_IF_CONCEPTS (   code)    code

Definition at line 548 of file cpp_standard.hpp.

◆ TRLC_IF_COROUTINES

#define TRLC_IF_COROUTINES (   code)    code

Definition at line 554 of file cpp_standard.hpp.

◆ TRLC_IF_CPP17

#define TRLC_IF_CPP17 (   code)    code

Definition at line 516 of file cpp_standard.hpp.

◆ TRLC_IF_CPP20

#define TRLC_IF_CPP20 (   code)    code

Definition at line 522 of file cpp_standard.hpp.

◆ TRLC_IF_CPP23

#define TRLC_IF_CPP23 (   code)

Definition at line 530 of file cpp_standard.hpp.

◆ TRLC_IF_RANGES

#define TRLC_IF_RANGES (   code)    code

Definition at line 560 of file cpp_standard.hpp.

◆ TRLC_IF_STRUCTURED_BINDINGS

#define TRLC_IF_STRUCTURED_BINDINGS (   code)    code

Definition at line 542 of file cpp_standard.hpp.