Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Stroika::Foundation::Common Namespace Reference

Namespaces

namespace  Private_
 

Classes

struct  Case
 
struct  ComparisonRelationDeclaration
 
struct  ComparisonRelationDeclarationBase
 
struct  ConvertibleFrom
 
struct  ConvertibleTo
 
struct  CountedValue
 
struct  DefaultNames
 
struct  Empty
 
class  EmptyObjectForSideEffects
 
struct  EqualsComparerAdapter
 Use this to wrap any basic comparer, and produce an Equals comparer. More...
 
class  ExtendableProperty
 ExtendableProperty is a Property which has callbacks associated with it, to be notified when it is accessed or updated. More...
 
struct  FunctionTraits
 Extract the number of arguments, return type, and each individual argument type from a lambda or simple function object. More...
 
struct  GUID
 
struct  Identity
 function object whose action is to map its argument, back to the same value it started with (identity function). More...
 
struct  InOrderComparerAdapter
 Use this to wrap any basic comparer, and produce a Less comparer. More...
 
struct  KeyValuePair
 
struct  LazyType
 
struct  OptionalThreeWayComparer
 ThreeWayComparer for optional types, like builtin one, except this lets you pass in explicit 'T' comparer for the T in optional<T> More...
 
class  Property
 
class  ReadOnlyProperty
 
class  ScopedUseLocale
 
struct  substitution_failure
 
struct  substitution_succeeded
 
struct  ThreeWayComparerAdapter
 Use this to wrap a basic (ITotallyOrderingComparer) comparer, and produce a Three-Way comparer. More...
 
struct  Version
 
class  WriteOnlyProperty
 

Concepts

concept  IPotentiallyComparer
 
concept  IComparer
 
concept  IEqualsComparer
 
concept  IInOrderComparer
 
concept  IThreeWayComparer
 
concept  ITotallyOrderingComparer
 
concept  IBuiltinArithmetic
 concept true if integral or floatpoint type 'T'. Not sure why not provided by std c++
 
concept  INoThrowInvocable
 like std::invocable concept, except also requires the invocation doesn't raise exceptions
 
concept  IAnyOf
 concept - trivial shorthand for variadic same_as A or same_as B, or ...
 
concept  trivially_copyable
 concept version of std::is_trivially_copyable_v
 
concept  Boolean_testable
 handy re-usable concept, with the obvious meaning, and strangely omitted from std-c++ (though used in exposition).
 
concept  Weak_Equality_Comparable_With
 equality_comparable_with, but less strict - just checks if it can be equality compared!
 
concept  explicitly_convertible_to
 like convertible_to, but also handling cases where T has an explict CTOR taking From
 
concept  IPair
 return true iff argument type T, is std::pair<a,b> for some a/b types
 
concept  ISharedPtr
 return true iff argument type T, is std::shared_ptr<A> for some A types
 
concept  ITuple
 Concept ITuple<T> check if T is a tuple.
 
concept  IVariant
 
  • detect if T is a std::variant<> type.

 
concept  IHasSizeMethod
 Concept checks if the given type T has a const size() method which can be called to return a size_t.
 
concept  IEqualToOptimizable
 
concept  IHasValueType
 Concept checks if the given type T has a value_type (type) member.
 
concept  IBoundedEnum
 

Typedefs

template<typename... >
using True = true_type
 
template<typename T >
using ExtractValueType_t = typename Private_::ExtractValueType< remove_cvref_t< T > >::type
 Extract the type of elements in a container, or returned by an iterator (value_type) or void it there is no value_type.
 
template<typename T >
using DifferenceType = typename conditional_t< is_enum_v< T >, LazyType< underlying_type_t, T >, LazyType< Private_::BaseDifferenceType_, T > >::type
 
template<typename T >
using UnsignedOfIf = typename conditional_t< is_integral_v< T >, LazyType< make_unsigned_t, T >, conditional< true, T, T > >::type
 
template<size_t N, class Type >
using RepeatedTuple_t = typename Private_::my_tuple< N, Type >::type
 same_as<RepeatedTuple_t<3,int>,tuple<int,int,int>>
 
template<typename T , typename CHECK_T = remove_cvref_t<T>>
using ArgByValueType = conditional_t<(sizeof(CHECK_T)<=2 *sizeof(void *)) and is_trivially_copyable_v< CHECK_T >, CHECK_T, const CHECK_T & >
 This is an alias for 'T' - but how we want to pass it on stack as formal parameter.
 

Enumerations

enum class  ComparisonRelationType { }
 
enum class  Endian
 in principle complicated question of correspondence between bit and byte and word numbering, but often fairly simple - similar to but subtler version of std::endian More...
 

Functions

template<typename FUNCTOR >
constexpr Common::ComparisonRelationDeclaration< ComparisonRelationType::eEquals, remove_cvref_t< FUNCTOR > > DeclareEqualsComparer (FUNCTOR &&f)
 DeclareEqualsComparer () marks a FUNCTOR (lambda or not) as being a FUNCTOR which compares for equality.
 
template<typename FUNCTOR >
constexpr Common::ComparisonRelationDeclaration< ComparisonRelationType::eStrictInOrder, remove_cvref_t< FUNCTOR > > DeclareInOrderComparer (FUNCTOR &&f)
 DeclareInOrderComparer () marks a FUNCTOR (lambda or not) as being a FUNCTOR which compares for in-order.
 
template<typename FROM_INT_TYPE >
constexpr strong_ordering CompareResultNormalizer (FROM_INT_TYPE f)
 
constexpr strong_ordering ReverseCompareOrder (strong_ordering so)
 
constexpr Endian GetEndianness ()
 returns native (std::endian::native) Endianness flag. Can be complicated (mixed, etc). But often very simple (e.g. Endian::eLittle) and for the simple cases, based on std::endian::native.
 
template<integral T>
constexpr T EndianConverter (T value, Endian from, Endian to)
 
template<typename ENUM >
constexpr ENUM Inc (ENUM e)
 Increment the given enumeration safely, without a bunch of casts.
 
template<typename ENUM >
constexpr underlying_type_t< ENUM > ToInt (ENUM e)
 Cast the given enum to an int (like static_cast<int>()) - but check range.
 
template<typename ENUM >
constexpr make_unsigned_t< underlying_type_t< ENUM > > GetDistanceSpanned (ENUM e)
 return the distance spanned by an enum, e.g. for use in an array
 
template<typename ENUM >
constexpr ENUM ToEnum (underlying_type_t< ENUM > e)
 Cast the given int to the given ENUM type - (like static_cast<int>()) - but check range.
 
template<typename ENUM >
constexpr make_unsigned_t< underlying_type_t< ENUM > > OffsetFromStart (ENUM e)
 offset of given enum from ENUM::eSTART
 
locale GetPlatformDefaultLocale ()
 
void UsePlatformDefaultLocaleAsDefaultLocale ()
 Set the operating system locale into the current C++ locale used by locale functions (and most locale-dependent stroika functions).
 
vector< Characters::StringGetAvailableLocales ()
 List all installed locale names (names which can be passed to std::locale::CTOR)
 
Characters::String FindLocaleName (const Characters::String &iso2LetterLanguageCode, const Characters::String &iso2LetterTerritoryCode)
 Not all systems appear to follow the same naming conventions for locales, so help lookup.
 
optional< Characters::StringFindLocaleNameQuietly (const Characters::String &iso2LetterLanguageCode, const Characters::String &iso2LetterTerritoryCode)
 Not all systems appear to follow the same naming conventions for locales, so help lookup.
 
locale FindNamedLocale (const Characters::String &iso2LetterLanguageCode, const Characters::String &iso2LetterTerritoryCode)
 Find the locale matching these properties (for exception trying)
 
SystemConfiguration GetSystemConfiguration ()
 Get the System Configuration object - note not a system global - because the configuration can change while the app is running.
 
SystemConfiguration::OperatingSystem GetSystemConfiguration_ActualOperatingSystem ()
 
SystemConfiguration::OperatingSystem GetSystemConfiguration_ApparentOperatingSystem ()
 
unsigned int GetNumberOfLogicalCPUCores (const chrono::duration< double > &allowedStaleness=1min)
 return the number of currently available CPU cores on this (virtual) machine
 
template<typename T , typename... ARGS>
T & Immortalize (ARGS... args)
 

Variables

template<typename ARG_T , IComparer< ARG_T > COMPARE_FUNCTION>
static constexpr ComparisonRelationType ExtractComparisonTraits_v
 ExtractComparisonTraits_v<> extracts the @ComparisonRelationType for the given argument comparer.
 
template<template< typename... > typename Detector, typename T , typename SFINAE = void>
constexpr bool is_detected_v = false
 

Detailed Description

TODO:

TODO:

Note
Code-Status: Alpha

Notes: I've long thought about doing something like this, but only recently got frustrated with the ugliness of tons of getters and setters. So I googled for solutions, and was surprised there was so little traction behind adding this feature to C++ (from C#).

These links give a few hints about discussions of adding this feature to c++:

TODO:

Typedef Documentation

◆ True

template<typename... >
using Stroika::Foundation::Common::True = typedef true_type

A template which ignores its template arguments, and always returns true_type; NOT crazy - helpful is template metaprogramming.

Definition at line 188 of file Concepts.h.

◆ ExtractValueType_t

template<typename T >
using Stroika::Foundation::Common::ExtractValueType_t = typedef typename Private_::ExtractValueType<remove_cvref_t<T> >::type

Extract the type of elements in a container, or returned by an iterator (value_type) or void it there is no value_type.

Note
when known if argument is container or iterator, use std::iter_value_t, or std::ranges::range_value_t

If the given T has a field value_type, return it; returns void if T has no value_type

NOTE - similar to std::ranges::range_value_t or std::iter_value_t except works with other types.

Definition at line 445 of file Concepts.h.

◆ DifferenceType

template<typename T >
using Stroika::Foundation::Common::DifferenceType = typedef typename conditional_t<is_enum_v<T>, LazyType<underlying_type_t, T>, LazyType<Private_::BaseDifferenceType_, T> >::type

Computes the difference between two types, plus for enums, returns the difference between the underlying types.

Example Usage
static_assert (same_as<DifferenceType<int>, int>);
static_assert (same_as<DifferenceType<double>, double>);

Definition at line 72 of file TemplateUtilities.h.

◆ UnsignedOfIf

template<typename T >
using Stroika::Foundation::Common::UnsignedOfIf = typedef typename conditional_t<is_integral_v<T>, LazyType<make_unsigned_t, T>, conditional<true, T, T> >::type

Given a type, if there is an unsigned variant of it, convert to that. Works for any type T (and returns T)

Example Usage
static_assert (same_as<UnsignedOfIf<int>, unsigned int>);
static_assert (same_as<UnsignedOfIf<string>, string>);
Note
conditional<true, T, T> is a trick similar to LazyType

Definition at line 86 of file TemplateUtilities.h.

◆ ArgByValueType

template<typename T , typename CHECK_T = remove_cvref_t<T>>
using Stroika::Foundation::Common::ArgByValueType = typedef conditional_t<(sizeof (CHECK_T) <= 2 * sizeof (void*)) and is_trivially_copyable_v<CHECK_T>, CHECK_T, const CHECK_T&>

This is an alias for 'T' - but how we want to pass it on stack as formal parameter.

This is NOT intended to be used very widely, but can be used to decide systematically (by type) if you should pass a given argument by value or by const reference.

Note
Use sizeof(T) <= 2*sizeof(void*) - because passing by reference involves copying one pointer and then if you access once, that's a second copy. So may as well copy 2 directly (very loosie goosy, as depends on relative cost of main memory access versus stack).

Definition at line 32 of file TypeHints.h.

Enumeration Type Documentation

◆ ComparisonRelationType

Comparison logic:

Total Ordering (http://mathworld.wolfram.com/TotallyOrderedSet.html)
o Reflexivity: a <= a o Antisymmetry: a <= b and b <= a implies a=b o Transitivity: a <= b and b <= c implies a <= c o Comparability: either a <= b or b <= a

Our comparisons ALL require Comparability; and all the <,<=,>,>= comparisons require Transitivity

Types of Comparers: <, <=, ==, etc, are functions from SxS => bool. They are also called relations (where the relationship need not be comparable). But in our domain, they are all comparable, so all comparers are function<bool(T,T)> - at least logically.

Most of Stroika's containers concern themselves with == testing. The value of == can always be derived from !=, <=, <, >, >=, though not necessarily very efficiently (the greater/less than ones translate one call to two).

A frequently more efficient strategy is compare(T,T)-> int (<0 is <, ==0, means equals, >0 means >). This strategy was widely used in the "C" world (e.g. strcmp, quicksort, etc).

It also appears to be making a comeback for C++20 (http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0515r0.pdf)

std-c++ favors a handful of these predefined functions > less > equal_to (to a lesser degree) but also provides > greater > less_equal > greater_equal > not_equal_to

c++ also appears to support this three-way-compare approach rarely (eg. string<>::compare).

The biggest problem with how std-c++ supports these comparison operators, is that typeid(equal_to<int>) is essentially unrelated to typeid(equal_to<char>). There is no 'tag' (as with bidirectional iterators etc) to identify different classes of comparison and so no easy to to leverage the natural relationships between equal_to and less_equal.

THIS is what drives how we do containers/related algorithms (less is equiv to greater for most of them)

Enumerator
eStrictInOrder 

e.g. less<T>, or greater<T>

From http://mathworld.wolfram.com/StrictOrder.html A relation < is a strict order on a set S if it is

  1. Irreflexive: a
eInOrderOrEquals 

<=, or >=, e.g. less_equal<T>, or greater_equal<T>

Note
considered the name 'partial' order here but that could be confusing, since partial order frequently refers to not covering the entire domain - not less vs. less_equal.
eThreeWayCompare 

e.g. function<int(T,T)> - where < 0 return is 'in order' (eStrictInOrder), 0 means equal, and > 0 means reversed order

Definition at line 71 of file Compare.h.

◆ Endian

in principle complicated question of correspondence between bit and byte and word numbering, but often fairly simple - similar to but subtler version of std::endian

See also
http://en.wikipedia.org/wiki/Endianness
https://en.cppreference.com/w/cpp/types/endian
Note
cannot use values from std::endian for matching cases (eBig/eLittle) because these values are impl defined

Definition at line 30 of file Endian.h.

Function Documentation

◆ DeclareEqualsComparer()

template<typename FUNCTOR >
constexpr Common::ComparisonRelationDeclaration< ComparisonRelationType::eEquals, remove_cvref_t< FUNCTOR > > Stroika::Foundation::Common::DeclareEqualsComparer ( FUNCTOR &&  f)
constexpr

DeclareEqualsComparer () marks a FUNCTOR (lambda or not) as being a FUNCTOR which compares for equality.

DeclareEqualsComparer is a trivial wrapper on ComparisonRelationDeclaration, but takes advantage of the fact that you can deduce types on functions arguments not not on type of object for constructor (at least as of C++17).

See also
DeclareInOrderComparer
EqualsComparerAdapter
Note
similar to InOrderComparerAdapter(), except this function ignores the TYEP of 'f' and just marks it as an InOrder comparer Whereas InOrderComparerAdapter looks at the type of 'f' and does the appropriate mapping logic.

Definition at line 31 of file Compare.inl.

◆ DeclareInOrderComparer()

template<typename FUNCTOR >
constexpr Common::ComparisonRelationDeclaration< ComparisonRelationType::eStrictInOrder, remove_cvref_t< FUNCTOR > > Stroika::Foundation::Common::DeclareInOrderComparer ( FUNCTOR &&  f)
constexpr

DeclareInOrderComparer () marks a FUNCTOR (lambda or not) as being a FUNCTOR which compares for in-order.

DeclareInOrderComparer is a trivial wrapper on ComparisonRelationDeclaration, but takes advantage of the fact that you can deduce types on functions arguments not not on type of object for constructor (at least as of C++17).

Example Usage:
constexpr auto kDefaultPrioritizedName_OrderByDefault_Less =
Stroika::Foundation::Common::DeclareInOrderComparer ([] (const PrioritizedName& lhs, const PrioritizedName& rhs) -> bool {
if (lhs.fPriority > rhs.fPriority) {
return true;
}
else if (lhs.fPriority < rhs.fPriority) {
return false;
}
return lhs.fName < rhs.fName;
});
constexpr Common::ComparisonRelationDeclaration< ComparisonRelationType::eStrictInOrder, remove_cvref_t< FUNCTOR > > DeclareInOrderComparer(FUNCTOR &&f)
DeclareInOrderComparer () marks a FUNCTOR (lambda or not) as being a FUNCTOR which compares for in-or...
Definition Compare.inl:44
See also
DeclareEqualsComparer
InOrderComparerAdapter
Note
similar to InOrderComparerAdapter(), except this function ignores the TYEP of 'f' and just marks it as an InOrder comparer Whereas InOrderComparerAdapter looks at the type of 'f' and does the appropriate mapping logic.

Definition at line 44 of file Compare.inl.

◆ CompareResultNormalizer()

template<typename FROM_INT_TYPE >
constexpr strong_ordering Stroika::Foundation::Common::CompareResultNormalizer ( FROM_INT_TYPE  f)
constexpr

Take the given value and map it to -1, 0, 1 - without any compiler warnings. Handy for 32/64 bit etc coding when you maybe comparing different sized values and just returning an int, but don't want the warnings about overflow etc.

Definition at line 226 of file Compare.inl.

◆ ReverseCompareOrder()

constexpr strong_ordering Stroika::Foundation::Common::ReverseCompareOrder ( strong_ordering  so)
constexpr

Map equals to equals, but less becomes greater and greater becomes less

Definition at line 242 of file Compare.inl.

◆ GetEndianness()

constexpr Endian Stroika::Foundation::Common::GetEndianness ( )
constexpr

returns native (std::endian::native) Endianness flag. Can be complicated (mixed, etc). But often very simple (e.g. Endian::eLittle) and for the simple cases, based on std::endian::native.

if (endian::native == endian::little) { return Endian::eLittle; } else if (endian::native == endian::big) { return Endian::eBig; } else complicated...

Definition at line 25 of file Endian.inl.

◆ EndianConverter()

template<integral T>
constexpr T Stroika::Foundation::Common::EndianConverter ( value,
Endian  from,
Endian  to 
)
constexpr

Utility to convert endianness. Logically this can be defined on any numeric integer type, but for now is restricted to uint16_t, uint32_t;

Its common, for example in networking, when you know the endianness of a source, or target data structure, and you can find YOUR machines endianness via GetEndianness (), this lets you automate the mapping (portably).

Example Usage
EXPECT_EQ (EndianConverter<uint16_t> (0xAABB, Endian::eBig, Endian::eLittle), 0xBBAA);
uint16_t useThisNumber = EndianConverter<uint16_t> (0xAABB, Endian::eBig, GetEndianness ());
constexpr Endian GetEndianness()
returns native (std::endian::native) Endianness flag. Can be complicated (mixed, etc)....
Definition Endian.inl:25
See also
https://en.cppreference.com/w/cpp/numeric/byteswap
GetEndianness

Definition at line 60 of file Endian.inl.

◆ Inc()

template<typename ENUM >
constexpr ENUM Stroika::Foundation::Common::Inc ( ENUM  e)
constexpr

Increment the given enumeration safely, without a bunch of casts.

\pre    ENUM uses  Stroika_Define_Enum_Bounds() to define eSTART, eEND
\pre    e >= typename ENUM::eSTART and e < typename ENUM::eEND

Definition at line 17 of file Enumeration.inl.

◆ ToInt()

template<typename ENUM >
constexpr underlying_type_t< ENUM > Stroika::Foundation::Common::ToInt ( ENUM  e)
constexpr

Cast the given enum to an int (like static_cast<int>()) - but check range.

\pre    ENUM uses  Stroika_Define_Enum_Bounds() to define eSTART, eEND
\pre    e >= typename ENUM::eSTART and e < typename ENUM::eEND

This function is handy since class enum's cannot be automatically promoted to integers.

Note
This function could have been called Ord () - to be more like Pascal.

Definition at line 28 of file Enumeration.inl.

◆ GetDistanceSpanned()

template<typename ENUM >
constexpr make_unsigned_t< underlying_type_t< ENUM > > Stroika::Foundation::Common::GetDistanceSpanned ( ENUM  e)
constexpr

return the distance spanned by an enum, e.g. for use in an array

Example Usage
enum class Priority {
a, b, c
};
unsigned int eltsWithPriority[GetDistanceSpanned<Priority> ()];
#define Stroika_Define_Enum_Bounds(FIRST_ITEM, LAST_ITEM)

◆ ToEnum()

template<typename ENUM >
constexpr ENUM Stroika::Foundation::Common::ToEnum ( underlying_type_t< ENUM >  e)
constexpr

Cast the given int to the given ENUM type - (like static_cast<int>()) - but check range.

\pre    ENUM uses  Stroika_Define_Enum_Bounds() to define eSTART, eEND
\pre    e >= typename ENUM::eSTART and e < typename ENUM::eEND

This function is handy since class enum's cannot be automatically promoted to integers.

Definition at line 52 of file Enumeration.inl.

◆ OffsetFromStart()

template<typename ENUM >
constexpr make_unsigned_t< underlying_type_t< ENUM > > Stroika::Foundation::Common::OffsetFromStart ( ENUM  e)
constexpr

offset of given enum from ENUM::eSTART

\pre    ENUM uses  Stroika_Define_Enum_Bounds() to define eSTART, eEND
\pre    e >= typename ENUM::eSTART and e < typename ENUM::eEND

Definition at line 65 of file Enumeration.inl.

◆ GetPlatformDefaultLocale()

std::locale Stroika::Foundation::Common::GetPlatformDefaultLocale ( )

In C++, the default locale is "C" (aka locale::classic ()), not the one inherited from the OS.

Its not hard to get/set the one from the OS, but I've found it not well documented, so this is intended to make it a little easier/more readable.

Definition at line 13 of file Locale.inl.

◆ UsePlatformDefaultLocaleAsDefaultLocale()

void Stroika::Foundation::Common::UsePlatformDefaultLocaleAsDefaultLocale ( )

Set the operating system locale into the current C++ locale used by locale functions (and most locale-dependent stroika functions).

In C++, the default locale is "C", not the one inherited from the OS. Its not hard to get/set the one from the OS, but I've found it not well documented, so this is intended to make it a little easier/more readable.

Definition at line 38 of file Locale.cpp.

◆ GetAvailableLocales()

vector< Characters::String > Stroika::Foundation::Common::GetAvailableLocales ( )

List all installed locale names (names which can be passed to std::locale::CTOR)

I'm quite surprised this appears so hard to to in stdC++. I must be missing something...

Definition at line 65 of file Locale.cpp.

◆ FindLocaleName()

Characters::String Stroika::Foundation::Common::FindLocaleName ( const Characters::String iso2LetterLanguageCode,
const Characters::String iso2LetterTerritoryCode 
)

Not all systems appear to follow the same naming conventions for locales, so help lookup.

Not all systems appear to follow the same naming conventions for locales, so provide a handy lookup function.

This will throw an exception if no matching locale is found

Definition at line 80 of file Locale.cpp.

◆ FindLocaleNameQuietly()

optional< Characters::String > Stroika::Foundation::Common::FindLocaleNameQuietly ( const Characters::String iso2LetterLanguageCode,
const Characters::String iso2LetterTerritoryCode 
)

Not all systems appear to follow the same naming conventions for locales, so help lookup.

Not all systems appear to follow the same naming conventions for locales, so provide a handy lookup function.

This will return nullopt if no matching locale is found

Definition at line 88 of file Locale.cpp.

◆ FindNamedLocale()

locale Stroika::Foundation::Common::FindNamedLocale ( const Characters::String iso2LetterLanguageCode,
const Characters::String iso2LetterTerritoryCode 
)

Find the locale matching these properties (for exception trying)

This will return a valid locale object with the prescribed properties, or it will raise an exception.

Definition at line 143 of file Locale.cpp.

◆ GetSystemConfiguration()

SystemConfiguration Stroika::Foundation::Common::GetSystemConfiguration ( )

Get the System Configuration object - note not a system global - because the configuration can change while the app is running.

Returns
SystemConfiguration

Definition at line 942 of file SystemConfiguration.cpp.

◆ GetSystemConfiguration_ActualOperatingSystem()

SystemConfiguration::OperatingSystem Stroika::Foundation::Common::GetSystemConfiguration_ActualOperatingSystem ( )

Return info about the actual operating system this software is running on (if possible to tell, it could be well hidden)

Often virtualization (things like compatability mode in a manifest, or perhaps docker, or WSL) makes the apprarent operating system different than the one you are actually running on).

Definition at line 550 of file SystemConfiguration.cpp.

◆ GetSystemConfiguration_ApparentOperatingSystem()

SystemConfiguration::OperatingSystem Stroika::Foundation::Common::GetSystemConfiguration_ApparentOperatingSystem ( )

Return info about the apparent operating system this software is running on.

Often virtualization (things like compatability mode in a manifest, or perhaps docker, or WSL) makes the apprarent operating system different than the one you are actually running on).

Definition at line 806 of file SystemConfiguration.cpp.

◆ GetNumberOfLogicalCPUCores()

unsigned int Stroika::Foundation::Common::GetNumberOfLogicalCPUCores ( const chrono::duration< double > &  allowedStaleness = 1min)

return the number of currently available CPU cores on this (virtual) machine

This is very roughly GetSystemConfiguration_CPU ().GetNumberOfLogicalCores () BUT - this CAN CHANGE over time, and this routine tries to provide a QUICK (cheap so not 100% guaranteed right) answer but generally will be quicker than GetSystemConfiguration_CPU ().GetNumberOfLogicalCores (), and provides stronger guaranteeds about accurance than std::thread::hardware_concurrency (https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency)

See also
GetSystemConfiguration_CPU
SystemConfiguration::CPU::GetNumberOfLogicalCores

Definition at line 910 of file SystemConfiguration.cpp.

◆ Immortalize()

template<typename T , typename... ARGS>
T & Stroika::Foundation::Common::Immortalize ( ARGS...  args)

Create a singleton of a class initialized once, but whose DTOR is never called.

Based on template <class _Ty> _Ty& _Immortalize() from VS2k19 runtime library....

Definition at line 14 of file TemplateUtilities.inl.

Variable Documentation

◆ ExtractComparisonTraits_v

template<typename ARG_T , IComparer< ARG_T > COMPARE_FUNCTION>
constexpr ComparisonRelationType Stroika::Foundation::Common::ExtractComparisonTraits_v
staticconstexpr
Initial value:
=
Private_::ExtractComparisonTraits_<ARG_T, remove_cvref_t<COMPARE_FUNCTION>>::kComparisonRelationKind

ExtractComparisonTraits_v<> extracts the @ComparisonRelationType for the given argument comparer.

For common builtin types this is known with no user effort. For user-defined comparers, this will need to be declared (e.g. via ComparisonRelationDeclarationBase)

This is ONLY defined for builtin c++ comparison objects, though your code can define it however you wish for specific user-defined types using ComparisonRelationDeclarationBase<>.

Definition at line 184 of file Compare.h.

◆ is_detected_v

template<template< typename... > typename Detector, typename T , typename SFINAE = void>
constexpr bool Stroika::Foundation::Common::is_detected_v = false
constexpr