Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
StdCompat.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include <bit>
#include <chrono>
#include <cmath>
#include <compare>
#include <concepts>
#include <cstdarg>
#include <ranges>
#include <variant>
#include "StdCompat.inl"

Go to the source code of this file.

Classes

class  Stroika::Foundation::Common::StdCompat::unexpected< T >
 
class  Stroika::Foundation::Common::StdCompat::expected< T, E >
 

Namespaces

namespace  Stroika::Foundation
 
namespace  Stroika::Foundation::Common
 

Concepts

concept  Stroika::Foundation::Common::StdCompat::BasicLockable
 Logically the C++ standard BasicLockable named requirement, but that was not included in std c++ library.
 
concept  Stroika::Foundation::Common::StdCompat::Lockable
 Logically the C++ standard Lockable named requirement, but that was not included in std c++ library.
 
concept  Stroika::Foundation::Common::StdCompat::TimedLockable
 Logically the C++ standard TimedLockable named requirement, but that was not included in std c++ library.
 
concept  Stroika::Foundation::Common::StdCompat::TimedMutex
 Logically the C++ standard TimedMutex named requirement, but that was not included in std c++ library.
 
concept  Stroika::Foundation::Common::StdCompat::Boolean_testable
 handy re-usable concept, with the obvious meaning, and strangely omitted from std-c++ (though used in exposition).
 
concept  Stroika::Foundation::Common::StdCompat::explicitly_convertible_to
 like convertible_to, but also handling cases where T has an explicit CTOR taking From
 

Macros

#define Stroika_ATTRIBUTE_INDETERMINATE
 Stroika_ATTRIBUTE_INDETERMINATE is used where you would use a C++ attribute for a variable that is intentionally uninitialized.
 
#define Stroika_ATTRIBUTE_ASSUME(X)
 Stroika_ATTRIBUTE_ASSUME(C) is used where you would put a C++ attribute assume expression, to assume a condition is true for a given block.
 
#define Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS
 Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS - used for the attribute [[no_unique_address]].
 
#define Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCFORCE   Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS
 [[msvc::no_unique_address]] isn't always broken in MSVC. Annotate with this on things where its not broken.
 
#define Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCBUGGY   Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS
 Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCBUGGY same as Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS.
 

Functions

template<class T >
T Stroika::Foundation::Common::StdCompat::byteswap (T n) noexcept
 
template<typename T >
constexpr bool Stroika::Foundation::Common::StdCompat::isinf (T v) noexcept
 
template<typename T >
constexpr bool Stroika::Foundation::Common::StdCompat::isnan (T v) noexcept
 

Detailed Description

The purpose of this module is to define any std c++ functions/classes etc - which may not be provided by the current std c++ library (often because not compiled with appropriate –std=... flag) - and/or because its an old compiler.

This also includes 'named requirements' - rendered as concepts (probably SHOULD be part of CPP standard but are not).

This doesn't strictly violate any rules about sticking stuff into namespace std - cuz we don't. That's why we use a separate namespace (that often just indirects to the namespace std - where the function/class is defined already).

A thin layer over the standard library: it includes nothing of Stroika's (beyond StroikaPreComp.h), so it is usable wherever std is.

Note
Code-Status: Beta

Definition in file StdCompat.h.

Macro Definition Documentation

◆ Stroika_ATTRIBUTE_INDETERMINATE

#define Stroika_ATTRIBUTE_INDETERMINATE

Stroika_ATTRIBUTE_INDETERMINATE is used where you would use a C++ attribute for a variable that is intentionally uninitialized.

[[indeterminate]] https://en.cppreference.com/w/cpp/language/attributes/indeterminate.html

Example Usage
Stroika_ATTRIBUTE_INDETERMINATE byte r[1024]; // don't initialize explicitly cuz filled in below before used (performance)
#define Stroika_ATTRIBUTE_INDETERMINATE
Stroika_ATTRIBUTE_INDETERMINATE is used where you would use a C++ attribute for a variable that is in...
Definition StdCompat.h:428

Definition at line 428 of file StdCompat.h.

◆ Stroika_ATTRIBUTE_ASSUME

#define Stroika_ATTRIBUTE_ASSUME (   X)

Stroika_ATTRIBUTE_ASSUME(C) is used where you would put a C++ attribute assume expression, to assume a condition is true for a given block.

The assume attribute was introduced in c++23, and Stroika OPTIONALLY supports this, but doesn't require it as of Stroika v3. So use Stroika_ATTRIBUTE_ASSUME () to conditionally use [[assume(X)]]

Definition at line 453 of file StdCompat.h.

◆ Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS

#define Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS

Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS - used for the attribute [[no_unique_address]].

MSVC accepts [[no_unique_address]] but ignores it, to keep its ABI, and supports [[msvc::no_unique_address]] instead (see qCompilerAndStdLib_NO_UNIQUE_ADDR_IgnoredAndMustUseMSVCNOUNIQUE_Buggy)

Definition at line 471 of file StdCompat.h.

◆ Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCBUGGY

#define Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCBUGGY   Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS

Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCBUGGY same as Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS.

EMPHASIZE that this is Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS and not Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCFORCE cuz its known buggy

Definition at line 490 of file StdCompat.h.

Function Documentation

◆ byteswap()

template<class T >
T Stroika::Foundation::Common::StdCompat::byteswap ( T  n)
noexcept

std::byteswap where the standard library has it (it is C++23), else an equivalent - so every C++20 build uses the version below.

Definition at line 228 of file StdCompat.h.

◆ isinf()

template<typename T >
constexpr bool Stroika::Foundation::Common::StdCompat::isinf ( T  v)
constexprnoexcept

std::isinf, but constexpr where the standard library allows it (C++23)

Definition at line 248 of file StdCompat.h.

◆ isnan()

template<typename T >
constexpr bool Stroika::Foundation::Common::StdCompat::isnan ( T  v)
constexprnoexcept

std::isnan, but constexpr where the standard library allows it (C++23)

Definition at line 262 of file StdCompat.h.