Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
feature_detection.h File Reference

Compiler and standard library feature detection. More...

Include dependency graph for feature_detection.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KCENON_HAS_SOURCE_LOCATION   0
 Detect std::source_location availability.
 
#define KCENON_HAS_JTHREAD   0
 Detect std::jthread and std::stop_token availability.
 
#define KCENON_HAS_STOP_TOKEN   0
 Detect std::stop_token availability separately.
 
#define KCENON_HAS_FORMAT   0
 Detect std::format availability.
 
#define KCENON_HAS_SPAN   0
 Detect std::span availability.
 
#define KCENON_HAS_RANGES   0
 Detect std::ranges availability.
 
#define KCENON_HAS_EXPECTED   0
 Detect std::expected availability.
 
#define KCENON_HAS_STACKTRACE   0
 Detect std::stacktrace availability.
 
#define KCENON_HAS_CONCEPTS   0
 Detect C++20 concepts availability.
 
#define KCENON_HAS_COROUTINES   0
 Detect C++20 coroutines availability.
 
#define KCENON_HAS_THREE_WAY_COMPARISON   0
 Detect C++20 three-way comparison (spaceship operator)
 
#define KCENON_HAS_OPTIONAL_MONADIC   0
 Detect std::optional monadic operations (C++23)
 
#define KCENON_HAS_CONSTEXPR_VECTOR   0
 Detect constexpr std::vector (C++20)
 
#define KCENON_HAS_CONSTEXPR_STRING   0
 Detect constexpr std::string (C++20)
 

Detailed Description

Compiler and standard library feature detection.

This file detects C++17/20/23 standard library features and provides unified KCENON_HAS_* macros for conditional compilation. All detection follows the official feature test macros from the C++ standard.

Detected features:

  • std::source_location (C++20)
  • std::jthread / std::stop_token (C++20)
  • std::format (C++20)
  • std::span (C++20)
  • std::ranges (C++20)
  • std::expected (C++23)
  • std::stacktrace (C++23)
See also
https://en.cppreference.com/w/cpp/feature_test for feature test macros

Definition in file feature_detection.h.

Macro Definition Documentation

◆ KCENON_HAS_CONCEPTS

#define KCENON_HAS_CONCEPTS   0

Detect C++20 concepts availability.

Definition at line 227 of file feature_detection.h.

◆ KCENON_HAS_CONSTEXPR_STRING

#define KCENON_HAS_CONSTEXPR_STRING   0

Detect constexpr std::string (C++20)

Definition at line 316 of file feature_detection.h.

◆ KCENON_HAS_CONSTEXPR_VECTOR

#define KCENON_HAS_CONSTEXPR_VECTOR   0

Detect constexpr std::vector (C++20)

Definition at line 301 of file feature_detection.h.

◆ KCENON_HAS_COROUTINES

#define KCENON_HAS_COROUTINES   0

Detect C++20 coroutines availability.

Definition at line 245 of file feature_detection.h.

◆ KCENON_HAS_EXPECTED

#define KCENON_HAS_EXPECTED   0

Detect std::expected availability.

std::expected provides a value-or-error wrapper similar to Result types in Rust and other languages.

Definition at line 189 of file feature_detection.h.

◆ KCENON_HAS_FORMAT

#define KCENON_HAS_FORMAT   0

Detect std::format availability.

std::format provides type-safe text formatting similar to Python's format strings and fmt library.

Definition at line 128 of file feature_detection.h.

◆ KCENON_HAS_JTHREAD

#define KCENON_HAS_JTHREAD   0

Detect std::jthread and std::stop_token availability.

std::jthread is a cooperative thread with automatic joining and stop_token support for cooperative cancellation.

Detection criteria:

  1. C++20 or later
  2. <thread> or <stop_token> header available
  3. __cpp_lib_jthread >= 201911L OR __cpp_lib_stop_token >= 201907L
Note
Some implementations may have stop_token without jthread. We check both for maximum compatibility.

Definition at line 93 of file feature_detection.h.

◆ KCENON_HAS_OPTIONAL_MONADIC

#define KCENON_HAS_OPTIONAL_MONADIC   0

Detect std::optional monadic operations (C++23)

Definition at line 282 of file feature_detection.h.

◆ KCENON_HAS_RANGES

#define KCENON_HAS_RANGES   0

Detect std::ranges availability.

C++20 Ranges library provides composable range adaptors and views.

Definition at line 168 of file feature_detection.h.

◆ KCENON_HAS_SOURCE_LOCATION

#define KCENON_HAS_SOURCE_LOCATION   0

Detect std::source_location availability.

std::source_location provides compile-time capture of source code location information (file, line, function).

Detection criteria:

  1. C++20 or later
  2. <source_location> header available
  3. __cpp_lib_source_location feature macro >= 201907L

Definition at line 60 of file feature_detection.h.

◆ KCENON_HAS_SPAN

#define KCENON_HAS_SPAN   0

Detect std::span availability.

std::span provides a non-owning view over a contiguous sequence of objects.

Definition at line 148 of file feature_detection.h.

◆ KCENON_HAS_STACKTRACE

#define KCENON_HAS_STACKTRACE   0

Detect std::stacktrace availability.

std::stacktrace provides portable stack trace information.

Definition at line 209 of file feature_detection.h.

◆ KCENON_HAS_STOP_TOKEN

#define KCENON_HAS_STOP_TOKEN   0

Detect std::stop_token availability separately.

Definition at line 107 of file feature_detection.h.

◆ KCENON_HAS_THREE_WAY_COMPARISON

#define KCENON_HAS_THREE_WAY_COMPARISON   0

Detect C++20 three-way comparison (spaceship operator)

Definition at line 264 of file feature_detection.h.