-
Notifications
You must be signed in to change notification settings - Fork 0
Basic Concepts
Dimo Markov edited this page May 23, 2024
·
4 revisions
Langulus::CT
is a namespace filled with all sorts of Compile-Time tools and ConcepTs. Most of them are very similar to ones already available in std
, however CT
gives the added benefit of making them all variadic to reduce boilerplate. You no longer have to do std::is_same<T1, T2> && std::is_same<T1, T3>
, instead you just write CT::Exact<T1, T2, T3>
. Many of the concepts will also ignore references, whenever that makes sense.
Langulus::Core
in particular serves only a small portion of these concepts. Here's a catalogue:
-
IsConstexpr(Lambda) -> bool
- check if a statement encapsulated in a lambda isconstexpr
. Leverages that lambda expressions can beconstexpr
as of C++17. -
Complete<T...>
- check if allT
are complete (defined), by exploitingsizeof
. Usefulness of this is limited to the first instantiation. Any other use is undefined and might produce wrong results on some compilers. Thankfully, most modern compilers do detect if a definition changes inbetween completeness checks, so it is highly unlikely it causes any real harm. -
Same<T1, TN...>
- true if decayedT1
matches all decayedTN
types. Ignores density and cv-qualifiers. -
SameAsOneOf<T1, TN...>
- true if decayedT1
matches at least one of the decayedTN
types. Ignores density and cv-qualifiers. -
Similar<T1, TN...>
- true if unqualifiedT1
matches all unqualifiedTN
types. Ignores only cv-qualifiers. -
SimilarAsOneOf<T1, TN...>
- true if unqualifiedT1
matches at least one of the unqualifiedTN
types. Ignores only cv-qualifiers. -
Exact<T1, TN...>
- true ifT1
matches allTN
types exactly, including any cv-qualifiers or indirections. -
ExactAsOneOf<T1, TN...>
- true ifT1
matches at least one ofTN
types exactly, including any cv-qualifiers or indirections. -
Array<T...>
- true if allT
are bounded array types. References will be ignored. Seestd::is_bounded_array_v
; -
Function<T...>
- true if allT
are raw function signatures. Seestd::is_function_v
-
Sparse<T...>
- true if allT
are pointers or bounded arrays. References will be ignored. -
Dense<T...>
- true if allT
are not pointers, nor bounded arrays. References will be ignored. -
Reference<T...>
- true if allT
are references. -
NotReference<T...>
- true if allT
are NOT references. -
Aggregate<T...>
- true if allT
are aggregate types. References will be ignored. -
NotAggregate<T...>
- true if allT
are NOT aggregate types. References will be ignored. -
Constant<T...>
- true if allT
areconst
on the top-most indirection. References will be ignored. -
Mutable<T...>
- true if allT
are notconst
on the top-most indirection. References will be ignored. -
Volatile<T...>
- true if allT
have thevolatile
qualifier. References will be ignored. -
Convoluted<T...>
- true if allT
have both theconst
and thevolatile
qualifiers. References will be ignored. -
Fundamental<T...>
- true if allT
are fundamental types. References will be ignored. -
Signed<T...>
- true if allT
are signed numbers.std::is_signed_v
is crap, because it assumes that all types are int-initializable. This one is better. Doesn't apply to numbers only, but anything negatable. -
Unsigned<T...>
- true if allT
are unsigned numbers. -
BuiltinBool<T...>
- true if allT
arebool
. -
BuiltinCharacter<T...>
- true if allT
are any of the built-in character types:char
,char8_t
,char16_t
,char32_t
,wchar_t
. Ignores references. -
BuiltinInteger<T...>
,BuiltinSignedInteger<T...>
,BuiltinUnsignedInteger<T...>
- true if allT
are any of the built-in integer types. Doesn't considerbool
to be an integer type (unlike::std::integral
). Ignores references. -
BuiltinReal<T...>
- true if allT
are any of the built-in floating number types. Ignores references. -
BuiltinNumber<T...>
- true if allT
are any of the built-in number types:BuiltinBool
,BuiltinCharacter
,BuiltinInteger
, orBuiltinReal
. Ignores references. -
StringLiteral<T...>
- true if allT
are string literals - bounded arrays with an extent. Ignores references. -
StringPointer<T...>
- true if allT
are string pointers, hopefully null-terminated. This account to all string pointers that do not have extents. Ignores references. -
String<T...>
- true if allT
are strings, eitherStringLiteral
orStringPointer
. Ignores references. -
StdContainer<T...>
- true if allT
arestd
containers that satisfy thestd::range::range
concept. -
StdContiguousContainer<T...>
- true if allT
are contiguousstd
containers that satisfy thestd::range::contiguous_range
concept. -
Convertible<FROM, TO...>
- true if FROM is convertible to allTO
types. Ignores references. -
Comparable<LHS, RHS...>
- true if LHS is equality-comparable (==
) to allRHS
types. -
Sortable<LHS, RHS...>
- true if LHS is lesser/greater-comparable (<
and>
) against allRHS
types. -
Enum<T...>
- check if allT
are enum types. Ignores references. -
Arithmetic<T...>
- check if allT
are arithmetic types. Ignores references. -
Referencable<T...>
- check if allT
implement the reference-counter interface. All must have theReference(Count) -> Count
method. -
Swappable<T...>
andSwappableNoexcept<T...>
- check if allT
are swappable with themselves. -
DerivedFrom<T, BASE...>
- check if the origin ofT
inherits allBASE
types. -
Related<T1, TN...>
- check if the origin ofT1
inherits allTN
types, or vice versa. -
VirtuallyDerivedFrom<T, BSAE...>
- check if the origin ofT
inherits allBASE
types virtually. -
BinaryCompatible<T1, TN...>
- check if types areRelated
and of the same size. -
Slab<T...>
- true if allT
aren't pointers, have no extents with [], and aren't references. -
Decayed<T...>
- checks whether allT
are fully decayed down to their origin types, with all their references, pointers and extents stripped away. -
NotDecayed<T...>
- checks whether allT
are not fully decayed, having a reference, pointer, or extent. -
Void<T...>
andTypeErased<T...>
- checks whether allT
are void types. -
Data<T...>
,DenseData<T...>
,SparseData<T...>
,DataReference<T...>
- checks whether allT
are NOT void types. -
Void<T...>
- checks whether allT
are exactlystd::nullptr_t
.