nkr
A C++20 library with a custom meta-programming language.
List of all members
nkr::constant_t< type_p, value_p > Class Template Reference

Represents an immutable literal value in a compile-time or run-time context. More...

aliases

using value_t = type_p
 The primary inner type of nkr::constant_t. More...
 

static functions

static constexpr value_t Value () noexcept
 Returns the primary inner value of an instantiated nkr::constant_t. More...
 

constructors

constexpr constant_t () noexcept
 
constexpr constant_t (const constant_t &other) noexcept
 
constexpr constant_t (const volatile constant_t &other) noexcept
 
constexpr constant_t (constant_t &&other) noexcept
 
constexpr constant_t (volatile constant_t &&other) noexcept
 

assigners

constexpr constant_toperator= (const constant_t &other) noexcept=delete
 
constexpr volatile constant_toperator= (const constant_t &other) volatile noexcept=delete
 
constexpr constant_toperator= (const volatile constant_t &other) noexcept=delete
 
constexpr volatile constant_toperator= (const volatile constant_t &other) volatile noexcept=delete
 
constexpr constant_toperator= (constant_t &&other) noexcept=delete
 
constexpr volatile constant_toperator= (constant_t &&other) volatile noexcept=delete
 
constexpr constant_toperator= (volatile constant_t &&other) noexcept=delete
 
constexpr volatile constant_toperator= (volatile constant_t &&other) volatile noexcept=delete
 

casters

constexpr operator nkr::constant_t< type_p, value_p >::value_t () const noexcept
 Casts to the primary inner value of an instanced nkr::constant_t. More...
 
constexpr operator nkr::constant_t< type_p, value_p >::value_t () const volatile noexcept
 Casts to the primary inner value of an instanced nkr::constant_t. More...
 

operators

constexpr value_t operator() () const noexcept
 Returns the primary inner value of an instanced nkr::constant_t. More...
 
constexpr value_t operator() () const volatile noexcept
 Returns the primary inner value of an instanced nkr::constant_t. More...
 

Detailed Description

template<nkr::cpp::type_tr type_p, type_p value_p>
class nkr::constant_t< type_p, value_p >

Represents an immutable literal value in a compile-time or run-time context.

nkr::constant_t is primarily used as a template type parameter in place of a template value parameter, for the sake of the one kind of template parameter design. However, there's nothing restricting its use in other contexts where desirable.

Note
nkr::constant_t is the primary entity of the nkr::constant_t Identity.

This type is similar to std::integral_constant.

Member Typedef Documentation

◆ value_t

template<nkr::cpp::type_tr type_p, type_p value_p>
using nkr::constant_t< type_p, value_p >::value_t = type_p

Member Function Documentation

◆ Value()

template<nkr::cpp::type_tr type_p, type_p value_p>
constexpr constant_t< type_p, value_p >::value_t nkr::constant_t< type_p, value_p >::Value
inlinestaticconstexprnoexcept

Returns the primary inner value of an instantiated nkr::constant_t.

This is a static function and not a method because the most frequent use case for nkr::constant_t is to be passed as a template argument, therefore it should be easily accessible through an instantiated type more so than as a type instance.

Because C++ does not allow for both a static function and a method to have the same label, we can only define one or the other. However, according to the primary inner value design the primary inner value is also accessible through the nkr::constant_t::operator ()() const and nkr::constant_t::operator nkr::constant_t::value_t() const methods as well as their volatile complements.

◆ operator nkr::constant_t< type_p, value_p >::value_t() [1/2]

template<nkr::cpp::type_tr type_p, type_p value_p>
constexpr nkr::constant_t< type_p, value_p >::operator nkr::constant_t< type_p, value_p >::value_t
inlineconstexprnoexcept

◆ operator nkr::constant_t< type_p, value_p >::value_t() [2/2]

template<nkr::cpp::type_tr type_p, type_p value_p>
constexpr nkr::constant_t< type_p, value_p >::operator nkr::constant_t< type_p, value_p >::value_t
inlineconstexprnoexcept

Casts to the primary inner value of an instanced nkr::constant_t.

This is the const volatile complement of nkr::constant_t::operator nkr::constant_t::value_t() const.

◆ operator()() [1/2]

template<nkr::cpp::type_tr type_p, type_p value_p>
constexpr constant_t< type_p, value_p >::value_t nkr::constant_t< type_p, value_p >::operator()
inlineconstexprnoexcept

◆ operator()() [2/2]

template<nkr::cpp::type_tr type_p, type_p value_p>
constexpr constant_t< type_p, value_p >::value_t nkr::constant_t< type_p, value_p >::operator()
inlineconstexprnoexcept