Stroika Library 3.0d23
 
Loading...
Searching...
No Matches
StdCompat.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include <bit>
#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::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 qStroika_ATTRIBUTE_INDETERMINATE
 qStroika_ATTRIBUTE_INDETERMINATE is used where you would use a C++ attribute for a variable that is intentionally uninitialized
 
#define qStroika_ATTRIBUTE_ASSUME(X)
 qStroika_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 qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS
 qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS - used for the attribute [[no_unique_address]]
 
#define qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCFORCE   qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS
 [[msvc::no_unique_address]] isn't always broken in MSVC. Annotate with this on things where its not broken.
 
#define qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCBUGGY   qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS
 qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCBUGGY same as qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS
 

Functions

template<class To , class From >
requires (sizeof (To) == sizeof (From) && std::is_trivially_copyable_v<From> && std::is_trivially_copyable_v<To>)
To Stroika::Foundation::Common::StdCompat::bit_cast (const From &src) noexcept
 
template<class 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).

Note
Code-Status: Beta

Definition in file StdCompat.h.

Macro Definition Documentation

◆ qStroika_ATTRIBUTE_INDETERMINATE

#define qStroika_ATTRIBUTE_INDETERMINATE

qStroika_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
qStroika_ATTRIBUTE_INDETERMINATE byte r[1024]; // don't initialize explicitly cuz filled in below before used (performance)
#define qStroika_ATTRIBUTE_INDETERMINATE
qStroika_ATTRIBUTE_INDETERMINATE is used where you would use a C++ attribute for a variable that is i...
Definition StdCompat.h:395

Definition at line 395 of file StdCompat.h.

◆ qStroika_ATTRIBUTE_ASSUME

#define qStroika_ATTRIBUTE_ASSUME (   X)

qStroika_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 qStroika_ATTRIBUTE_ASSUME () to conditionally use [[assume(X)]]

Definition at line 412 of file StdCompat.h.

◆ qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS

#define qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS

qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS - used for the attribute [[no_unique_address]]

Though all the compilers we target SOMEWHAT support this, MSVC appears to support it by ignoring it. Which is crazy cuz it DOES support msvc::no_unique_address

Definition at line 435 of file StdCompat.h.

◆ qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCBUGGY

#define qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCBUGGY   qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS

qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCBUGGY same as qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS

EMPHASIZE that this is qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS and not qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCFORCE cuz its known buggy

Definition at line 454 of file StdCompat.h.

Function Documentation

◆ bit_cast()

template<class To , class From >
requires (sizeof (To) == sizeof (From) && std::is_trivially_copyable_v<From> && std::is_trivially_copyable_v<To>)
To Stroika::Foundation::Common::StdCompat::bit_cast ( const From &  src)
noexcept

Workaround absence of bit_cast in MacOS XCode 14 (which we support with Stroika v3)

Definition at line 161 of file StdCompat.h.

◆ byteswap()

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

Workaround absence of byteswap gcc up to version 12, and clang (up to 14).

Definition at line 179 of file StdCompat.h.

◆ isinf()

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

workaround qCompilerAndStdLib_fpclasifyEtcOfInteger_Buggy

Definition at line 202 of file StdCompat.h.

◆ isnan()

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

workaround qCompilerAndStdLib_fpclasifyEtcOfInteger_Buggy

Definition at line 223 of file StdCompat.h.