spy v3.0.0
Andrée Borrel
Loading...
Searching...
No Matches
Language Standards

The C++ standard in force, and the C and C++ standard library implementations. More...

Detailed Description

The C++ standard in force, and the C and C++ standard library implementations.

What the code is allowed to say and what it can call: the standard the compiler was told to follow, and the two library implementations behind the headers it includes.

Variables

constexpr spy_implementation_defined spy::cpp_standard {}
 C++ standard version reporting value.
constexpr auto spy::libc = libc_type {}
 LIBC version reporting value.
constexpr auto spy::stdlib = stdlib_type {}
 C++ Standard Library version reporting value.

Functions

template<char... c>
constexpr auto spy::literal::operator""_cloud ()
 User-defined suffix for the CloudABI libc version definition.
template<char... c>
constexpr auto spy::literal::operator""_cpp ()
 User-defined suffix for C++ standard definition.
template<char... c>
constexpr auto spy::literal::operator""_gnu ()
 User-defined suffix for the GNU libc version definition.
template<char... c>
constexpr auto spy::literal::operator""_uc ()
 User-defined suffix for the uClibc version definition.
template<char... c>
constexpr auto spy::literal::operator""_vms ()
 User-defined suffix for the VMS libc version definition.
template<char... c>
constexpr auto spy::literal::operator""_zos ()
 User-defined suffix for the zOS libc version definition.

Variable Documentation

◆ cpp_standard

spy_implementation_defined spy::cpp_standard {}
inlineconstexpr

#include <spy/standard.hpp>

C++ standard version reporting value.

The spy::cpp_standard object can be compared to any other C++ standard related value to verify if the code being compiled with a specific version of the C++ standard. It reports 20, 23 or 26, and 0 when the standard version is unknown.

The targeted version is specified either as an integer or with the _cpp literal.

Example

#include <spy/spy.hpp>
#include <iostream>
int main()
{
std::cout << "This code compiled with " << spy::cpp_standard << ".\n";
// Version checks
using namespace spy::literal;
if constexpr(spy::cpp_standard == 20_cpp) std::cout << "This code compiled with C++ 20.\n";
if constexpr(spy::cpp_standard == 20) std::cout << "This code compiled with C++ 20.\n";
if constexpr(spy::cpp_standard >= 17_cpp)
std::cout << "This code compiled with C++ 17 or ulterior.\n";
if constexpr(spy::cpp_standard >= 17)
std::cout << "This code compiled with C++ 17 or ulterior.\n";
}
constexpr spy_implementation_defined cpp_standard
C++ standard version reporting value.
Definition standard.hpp:78

◆ libc

auto spy::libc = libc_type {}
inlineconstexpr

#include <spy/libc.hpp>

LIBC version reporting value.

The spy::libc object can be compared to any other libc related value to verify if the code being compiled with a specific version of the libc.

Any libc related value can be checked for equality or ordering for a given version. The targeted version is then specified using a libc-dependent literal.

Additionally, any of the libc related value are convertible to bool. They evaluates to true if they matches the correct libc currently used.

Supported Value

Name Vendor
spy::cloudabi_ CloudABI
spy::uc_ uClibc
spy::vms_ VMS
spy::zos_ zOS
spy::gnu_ GNU

Example

#include <iostream>
#include <spy/spy.hpp>
int main()
{
// Comparisons
if constexpr(spy::libc == spy::gnu_) std::cout << "This code is compiled with the GNU libc.\n";
else if constexpr(spy::libc == spy::zos_)
std::cout << "This code is compiled with the zOS libc.\n";
else if constexpr(spy::libc == spy::vms_)
std::cout << "This code is compiled with the VMS libc.\n";
// Direct test
if constexpr(spy::gnu_) std::cout << "This code is compiled with the GNU libc.\n";
else if constexpr(spy::zos_) std::cout << "This code is compiled with the zOS libc.\n";
else if constexpr(spy::vms_) std::cout << "This code is compiled with the VMS libc.\n";
}
constexpr auto libc
LIBC version reporting value.
Definition libc.hpp:130

◆ stdlib

auto spy::stdlib = stdlib_type {}
inlineconstexpr

#include <spy/stdlib.hpp>

C++ Standard Library version reporting value.

The spy::stdlib object can be compared to any other stdlib related value to verify if the code being compiled with a specific version of the C++ standard library.

Any stdlib related value can be checked for equality or ordering for a given version. The targeted version is then specified using a stdlib-dependent literal.

Additionally, any of the stdlib related value are convertible to bool. They evaluates to true if they matches the correct standard library currently used.

Supported Value

Name Vendor
spy::libcpp_ Clang libcpp
spy::gnucpp_ GNU C++ standard library

Example

#include <iostream>
#include <spy/spy.hpp>
int main()
{
// Comparisons
if constexpr(spy::stdlib == spy::gnucpp_)
std::cout << "This code is compiled with the GNU stdlib.\n";
else if constexpr(spy::stdlib == spy::libcpp_)
std::cout << "This code is compiled with the Clang stdlib.\n";
// Direct test
if constexpr(spy::gnucpp_) std::cout << "This code is compiled with the GNU stdlib.\n";
else if constexpr(spy::libcpp_) std::cout << "This code is compiled with the Clang stdlib.\n";
}
constexpr auto stdlib
C++ Standard Library version reporting value.
Definition stdlib.hpp:102