Table of Contents
Documentation¶
The newtype
library provides types and functions to facilitate the creation of strong type aliases.
Example Usage¶
Note
All examples shown in this section can be found in the directory examples/src
within the source root.
Basic usage of new_type below demonstrates the basic usage of new_type
.
In it, new_type
is used to create thre new strong aliases Width
, Height
, and Area
that all alias unsigned int
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <newtype/new_type.hpp>
#include <iostream>
using Width = nt::new_type<unsigned int, struct width_tag>;
using Height = nt::new_type<unsigned int, struct height_tag>;
using Area = nt::new_type<unsigned int, struct area_tag>;
struct Rectangle
{
constexpr Rectangle(Width w, Height h)
: width{w}
, height{h}
{
}
auto constexpr area() const noexcept -> Area
{
return {width.decay() * height.decay()};
}
private:
Width width;
Height height;
};
int main()
{
auto w{0u}, h{0u};
std::cin >> w >> h;
auto width = Width{w};
auto height = Height{h};
auto rect = Rectangle{width, height};
std::cout << rect.area().decay() << '\n';
}
|
However, using new_type
in this fashion seem quite cumbersome.
Starting from the bottom, unsigned int
can normally be shifted on to any std::basic_ostream
, like std::cout
in this example.
Since printing values, among other things, is a common scenario, newtype
provides facilities to support automatic derivation of supporting functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <newtype/derivable.hpp>
#include <newtype/deriving.hpp>
#include <newtype/new_type.hpp>
#include <iostream>
using Width = nt::new_type<unsigned int, struct width_tag>;
using Height = nt::new_type<unsigned int, struct height_tag>;
using Area = nt::new_type<unsigned int, struct area_tag, deriving(nt::Show)>;
struct Rectangle
{
constexpr Rectangle(Width w, Height h)
: width{w}
, height{h}
{
}
auto constexpr area() const noexcept -> Area
{
return {width.decay() * height.decay()};
}
private:
Width width;
Height height;
};
int main()
{
auto w{0u}, h{0u};
std::cin >> w >> h;
auto width = Width{w};
auto height = Height{h};
auto rect = Rectangle{width, height};
std::cout << rect.area() << '\n';
}
|
Improved usability using the Show derivation tag demonstrates how the function template deriving()
can be used to enable automatic derivation of the stream output operator for Area
.
Similarly, it is possible to derive the stream input operators of Width
and Height
, as shown in Deriving input operations using the Read derivation tag below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <newtype/derivable.hpp>
#include <newtype/deriving.hpp>
#include <newtype/new_type.hpp>
#include <iostream>
using Width = nt::new_type<unsigned int, struct width_tag, deriving(nt::Read)>;
using Height = nt::new_type<unsigned int, struct height_tag, deriving(nt::Read)>;
using Area = nt::new_type<unsigned int, struct area_tag, deriving(nt::Show)>;
struct Rectangle
{
constexpr Rectangle(Width w, Height h)
: width{w}
, height{h}
{
}
auto constexpr area() const noexcept -> Area
{
return {width.decay() * height.decay()};
}
private:
Width width;
Height height;
};
int main()
{
auto width = Width{};
auto height = Height{};
std::cin >> width >> height;
auto rect = Rectangle{width, height};
std::cout << rect.area() << '\n';
}
|
API¶
This section of the documentation describes the public API of the new_type.
It provides detailed descriptions of the types and functions designed to be used by applications.
All declarations described in this section are found in the namespace nt
, unless noted otherwise.
Header <newtype/new_type.hpp>
¶
This header contains the definitions of the class template new_type
as well as a set of associated namespace-level functions.
Class template new_type
¶
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
= deriving()>
classnew_type
¶ The class template
new_type
is designed to allow the creation of new types based on existing types. Similarly to the Haskell newtype, this class template creates a new type that is layout equivalent to the underlying type.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
New in version 1.0.0.
Member Type Aliases
-
using
derivation_clause_type
= decltype(DerivationClause)¶
-
using
iterator
= typename BaseType::iterator¶ - Enablement
This type alias shall be defined iff. this
new_type
’sbase_type
has a member typeiterator
and thederivation clause
containsIterable
.
New in version 1.1.0.
-
using
const_iterator
= typename BaseType::const_iterator¶ - Enablement
This type alias shall be defined iff. this
new_type
’sbase_type
has a member typeconst_iterator
and thederivation clause
containsIterable
.
New in version 1.1.0.
-
using
reverse_iterator
= typename BaseType::reverse_iterator¶ - Enablement
This type alias shall be defined iff. this
new_type
’sbase_type
has a member typereverse_iterator
and thederivation clause
containsIterable
.
New in version 1.1.0.
-
using
const_reverse_iterator
= typename BaseType::const_reverse_iterator¶ - Enablement
This type alias shall be defined iff. this
new_type
’sbase_type
has a member typeconst_reverse_iterator
and thederivation clause
containsIterable
.
New in version 1.1.0.
Static Data Members
-
static derivation_clause_type constexpr
derivation_clause
= DerivationClause¶
Constructors
-
constexpr
new_type
()¶ Construct a new instance of this
new_type
by default constructing the contained object.- Throws
Any exception thrown by the default constructor of this
new_type
’sbase_type
. This constructor shall be noexcept iff. thisnew_type
’sbase_type
is nothrow default-construtible.- Enablement
This constructor shall be defined as
= default
iff. thisnew_type
’sbase_type
is default-construtible. Otherwise, this constructor shall be explicitely deleted.
-
constexpr
new_type
(new_type const &other)¶ Construct a new instance of this
new_type
by copy-constructing the contained object using the value contained byother
.- Parameters
other – An existing instance of this
new_type
- Throws
Any exception thrown by the copy-constructor of this
new_type
’sbase_type
. This constructor shall be noexcept iff. thisnew_type
’sbase_type
is nothrow copy-construtible.- Enablement
This constructor shall be defined as
= default
iff. thisnew_type
’sbase_type
is copy-construtible. Otherwise, this constructor shall be explicitely deleted.
-
constexpr
new_type
(new_type &&other)¶ Construct a new instance of this
new_type
by move-constructing the contained object using the value contained byother
.- Parameters
other – An existing instance of this
new_type
- Throws
Any exception thrown by the move-constructor of this
new_type
’sbase_type
. This constructor shall be noexcept iff. thisnew_type
’sbase_type
is nothrow move-construtible.- Enablement
This constructor shall be defined as
= default
iff. thisnew_type
’sbase_type
is move-construtible. Otherwise, this constructor shall be explicitely deleted.
-
constexpr
new_type
(BaseType const &value)¶ Construct a new instance of this
new_type
by copy-constructing the contained object usingvalue
.- Parameters
value – An existing instance of this
new_type
- Throws
Any exception thrown by the copy-constructor of this
new_type
’sbase_type
. This constructor shall be noexcept iff. thisnew_type
’sbase_type
is nothrow copy-construtible.- Enablement
This constructor shall be defined as
= default
iff. thisnew_type
’sbase_type
is copy-construtible. Otherwise, this constructor shall be explicitely deleted.
-
constexpr
new_type
(BaseType &&value)¶ Construct a new instance of this
new_type
by move-constructing the contained object usingvalue
.- Parameters
value – An existing instance of this
new_type
- Throws
Any exception thrown by the move-constructor of this
new_type
’sbase_type
. This constructor shall be noexcept iff. thisnew_type
’sbase_type
is nothrow move-construtible.- Enablement
This constructor shall be defined as
= default
iff. thisnew_type
’sbase_type
is move-construtible. Otherwise, this constructor shall be explicitely deleted.
Assignment Operators
-
constexpr new_type &
operator=
(new_type const &other)¶ Copy the value of an existing instance of this
new_type
and replace this instance’s value- Parameters
other – An existing instance of this
new_type
- Throws
Any exception thrown by the copy-assignment operator of this
new_type
’sbase_type
. This operator shall be noexcept iff. thisnew_type
’sbase_type
is nothrow copy-assignable.- Enablement
This operator shall be defined as
= default
iff. thisnew_type
’sbase_type
is copy-assignable. Otherwise, this operator shall be explicitely deleted.
-
constexpr new_type &
operator=
(new_type &&other)¶ Move the value of an existing instance of this
new_type
and replace this instance’s value- Parameters
other – An existing instance of this
new_type
- Throws
Any exception thrown by the move-assignment operator of this
new_type
’sbase_type
. This operator shall be noexcept iff. thisnew_type
’sbase_type
is nothrow move-assignable.- Enablement
This operator shall be defined as
= default
iff. thisnew_type
’sbase_type
is move-assignable. Otherwise, this operator shall be explicitely deleted.
Accessors
-
constexpr
operator BaseType
() const¶ Retrieve a copy of the object contained by this
new_type
object- Throws
Any exception thrown by the copy-constructor of this
new_type
’sbase_type
. This operator shall be noexcept iff. thisnew_type
’sbase_type
is nothrow copy-constructible.- Explicit
This conversion operator shall be explicit unless this
new_type
’sderivation clause
containsImplicitConversion
.
Member Access Through Pointer
-
constexpr BaseType
operator->
() noexcept¶ Perform “member access through pointer” via a pointer to object contained by this
new_type
- Enablement
This operator shall be available iff. this
new_type
’sderivation clause
containsIndirection
-
constexpr BaseType const *
operator->
() const noexcept¶ Perform “member access through pointer” via a pointer to object contained by this
new_type
- Enablement
This operator shall be available iff. this
new_type
’sderivation clause
containsIndirection
Iterators
-
constexpr iterator
begin
()¶ Get an iterator to the beginning of the object contained by this
new_type
- Enablement
This function shall be available iff.
New in version 1.1.0.
-
constexpr iterator
begin
() const¶ Get a constant iterator to the beginning of the object contained by this
new_type
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andthis
new_type
’sbase type
has a non-static member functionbegin() const
that returns an instance of typeconst_iterator
New in version 1.1.0.
-
constexpr iterator
cbegin
() const¶ Get a constant iterator to the beginning of the object contained by this
new_type
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andthis
new_type
’sbase type
has a non-static member functioncbegin() const
that returns an instance of typeconst_iterator
New in version 1.1.0.
-
constexpr iterator
rbegin
()¶ Get a reverse iterator to the beginning of the object contained by this
new_type
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andthis
new_type
’sbase type
has a non-static member functionrbegin()
that returns an instance of typereverse_iterator
New in version 1.1.0.
-
constexpr iterator
rbegin
() const¶ Get a constant reverse iterator to the beginning of the object contained by this
new_type
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andthis
new_type
’sbase type
has a non-static member functionrbegin() const
that returns an instance of typeconst_reverse_iterator
New in version 1.1.0.
-
constexpr iterator
crbegin
() const¶ Get a constant reverse iterator to the beginning of the object contained by this
new_type
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andthis
new_type
’sbase type
has a non-static member functioncrbegin() const
that returns an instance of typeconst_reverse_iterator
New in version 1.1.0.
-
constexpr iterator
end
()¶ Get an iterator beyond the end of the object contained by this
new_type
- Enablement
This function shall be available iff.
New in version 1.1.0.
-
constexpr iterator
end
() const¶ Get a constant iterator beyond the end of the object contained by this
new_type
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andthis
new_type
’sbase type
has a non-static member functionend() const
that returns an instance of typeconst_iterator
New in version 1.1.0.
-
constexpr iterator
cend
() const¶ Get a constant iterator beyond the end of the object contained by this
new_type
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andthis
new_type
’sbase type
has a non-static member functioncend() const
that returns an instance of typeconst_iterator
New in version 1.1.0.
-
constexpr iterator
rend
()¶ Get a reverse iterator beyond the end of the object contained by this
new_type
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andthis
new_type
’sbase type
has a non-static member functionrend()
that returns an instance of typereverse_iterator
New in version 1.1.0.
-
constexpr iterator
rend
() const¶ Get a constant reverse iterator beyond the end of the object contained by this
new_type
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andthis
new_type
’sbase type
has a non-static member functionrend() const
that returns an instance of typeconst_reverse_iterator
New in version 1.1.0.
-
constexpr iterator
crend
() const¶ Get a constant reverse iterator beyond the end of the object contained by this
new_type
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andthis
new_type
’sbase type
has a non-static member functioncrend() const
that returns an instance of typeconst_reverse_iterator
New in version 1.1.0.
namespace
-level functions and function templates¶
The functions and functions templates described in this section provide additional functionality for the class template new_type
that is not part of the class itself.
Equality Comparison Operators¶
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr booloperator==
(new_type<BaseType, TagType, DerivationClause> const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Check two instances of
new_type<BaseType, TagType, DerivationClause>
for equality.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the comparison
rhs – The right-hand side of the comparison
- Returns
The value returned by the comparison of the contained objects.
- Throws
Any exception thrown by the comparison operator of objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow equals-comparable.- Enablement
This operator shall be available iff.
new_type::base_type
supports comparison using==
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr booloperator==
(new_type<BaseType, TagType, DerivationClause> const &lhs, BaseType const &rhs)¶ Check an instance of
new_type<BaseType, TagType, DerivationClause>
for equality with an instance ofBaseType
.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the comparison
rhs – The right-hand side of the comparison
- Returns
The value returned by the comparison of object contained by
lhs
with an object of thebase type
.- Throws
Any exception thrown by the comparison of object contained by
lhs
with an object of thebase type
. This operator shall be noexcept iff.new_type::base_type
is nothrow equals-comparable.- Enablement
This operator shall be available iff.
new_type::base_type
supports comparison using==
andthe
derivation clause
containsEqBase
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr booloperator==
(BaseType const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Check an instance of
BaseType
for equality with an instance ofnew_type<BaseType, TagType, DerivationClause>
.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the comparison
rhs – The right-hand side of the comparison
- Returns
The value returned by the comparison of an object of
base type
with the object contained byrhs
.- Throws
Any exception thrown by the comparison of an object of
base type
with the object contained byrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow equals-comparable.- Enablement
This operator shall be available iff.
new_type::base_type
supports comparison using==
andthe
derivation clause
containsEqBase
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr booloperator!=
(new_type<BaseType, TagType, DerivationClause> const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Check two instances of
new_type<BaseType, TagType, DerivationClause>
for in-equality.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the comparison
rhs – The right-hand side of the comparison
- Returns
The value returned by the comparison of the contained objects.
- Throws
Any exception thrown by the comparison operator of theobjects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow not-equals-comparable.- Enablement
This operator shall be available iff.
new_type::base_type
supports comparison using!=
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr booloperator!=
(new_type<BaseType, TagType, DerivationClause> const &lhs, BaseType const &rhs)¶ Check an instance of
new_type<BaseType, TagType, DerivationClause>
for in-equality with an instance ofBaseType
.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the comparison
rhs – The right-hand side of the comparison
- Returns
The value returned by the comparison of the object contained by
lhs
with an object of thebase type
.- Throws
Any exception thrown by the comparison of the object contained by
lhs
with an object of thebase type
. This operator shall be noexcept iff.new_type::base_type
is nothrow not-equals-comparable.- Enablement
This operator shall be available iff.
new_type::base_type
supports comparison using!=
andthe
derivation clause
containsEqBase
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr booloperator!=
(BaseType const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Check an instance of
BaseType
for in-equality with an instance ofnew_type<BaseType, TagType, DerivationClause>
.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the comparison
rhs – The right-hand side of the comparison
- Returns
The value returned by the comparison of an object of
base type
with the object contained byrhs
.- Throws
Any exception thrown by the comparison of an object of
base type
with the object contained byrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow not-equals-comparable.- Enablement
This operator shall be available iff.
new_type::base_type
supports comparison using!=
andthe
derivation clause
containsEqBase
New in version 1.0.0.
Relational Comparison Operators¶
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr booloperator<
(new_type<BaseType, TagType, DerivationClause> const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Compare two instances of the same
new_type
using<
(less-than).- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the comparison
rhs – The right-hand side of the comparison
- Returns
The value returned by the comparison of the contained objects.
- Throws
Any exception thrown by the comparison operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow less-than-comparable.- Enablement
This operator shall be available iff.
new_type::base_type
supports comparison using<
andthe
derivation clause
containsRelational
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr booloperator>
(new_type<BaseType, TagType, DerivationClause> const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Compare two instances of the same
new_type
using>
(greater-than).- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the comparison
rhs – The right-hand side of the comparison
- Returns
The value returned by the comparison of the contained objects.
- Throws
Any exception thrown by the comparison operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow greater-than-comparable.- Enablement
This operator shall be available iff.
new_type::base_type
supports comparison using>
andthe
derivation clause
containsRelational
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr booloperator<=
(new_type<BaseType, TagType, DerivationClause> const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Compare two instances of the same
new_type
using<=
(less-than-equal).- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the comparison
rhs – The right-hand side of the comparison
- Returns
The value returned by the comparison of the contained objects.
- Throws
Any exception thrown by the comparison operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow less-than-equal-comparable.- Enablement
This operator shall be available iff.
new_type::base_type
supports comparison using<=
andthe
derivation clause
containsRelational
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr booloperator>=
(new_type<BaseType, TagType, DerivationClause> const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Compare two instances of the same
new_type
using>=
(greater-than-equal).- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the comparison
rhs – The right-hand side of the comparison
- Returns
The value returned by the comparison of the contained objects.
- Throws
Any exception thrown by the comparison operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow greater-than-equal-comparable.- Enablement
This operator shall be available iff.
new_type::base_type
supports comparison using>=
andthe
derivation clause
containsRelational
New in version 1.0.0.
Stream I/O Operators¶
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
, typenameCharType
, typenameStreamTraits
>
std::basic_ostream<CharType, StreamTraits> &operator<<
(std::basic_ostream<CharType, StreamTraits> &out, new_type<BaseType, TagType, DerivationClause> const &value)¶ Write an instance of
new_type<BaseType, TagType, DerivationClause>
to a standardostream
.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
CharType – The stream character type
StreamTraits – The traits of the output stream
- Parameters
out – The output stream
value – A
new_type
value to write to the output stream
- Returns
A reference to the output stream
- Throws
Any exception thrown by the stream-output operator of the object contained by
value
. This operator shall be noexcept iff.new_type::base_type
is nothrow output-streamable.- Enablement
This operator shall be available iff.
new_type::base_type
supports being written to an output stream using<<
andthe
derivation clause
containsShow
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
, typenameCharType
, typenameStreamTraits
>
std::basic_istream<CharType, StreamTraits> &operator>>
(std::basic_istream<CharType, StreamTraits> &in, new_type<BaseType, TagType, DerivationClause> &value)¶ Read an instance of
new_type<BaseType, TagType, DerivationClause>
from a standardistream
.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
CharType – The stream character type
StreamTraits – The traits of the input stream
- Parameters
in – The input stream
value – A
new_type
value to be read from the output stream
- Returns
A reference to the input stream
- Throws
Any exception thrown by the stream-input operator of the object contained by
value
. This operator shall be noexcept iff.new_type::base_type
is nothrow input-streamable.- Enablement
This operator shall be available iff.
new_type::base_type
supports being read from an input stream using>>
andthe
derivation clause
containsRead
New in version 1.0.0.
Arithmetic Operators¶
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>operator+
(new_type<BaseType, TagType, DerivationClause> const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Add two instances of the same
new_type
.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the addition
rhs – The right-hand side of the addition
- Returns
A new instance of
new_type<BaseType, TagType, DerivationClause>
containing the result of applying+
to the objects contained bylhs
andrhs
.- Throws
Any exception thrown by the addition operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow addable andnew_type::base_type
is nothrow copy-constructible
- Enablement
This operator shall be available iff.
new_type::base_type
supports addition using+
andthe
derivation clause
containsArithmetic
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause> &operator+=
(new_type<BaseType, TagType, DerivationClause> &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Add two instances of the same
new_type
by overwriting the first one.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the addition
rhs – The right-hand side of the addition
- Returns
A reference to the first argument containing the value modified by applying
+=
to the objects contained bylhs
andrhs
.- Throws
Any exception thrown by the addition-assignment operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow add-assignable andnew_type::base_type
is nothrow copy-constructible
- Enablement
This operator shall be available iff.
new_type::base_type
supports addition using+=
andthe
derivation clause
containsArithmetic
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>operator-
(new_type<BaseType, TagType, DerivationClause> const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Subtract two instances of the same
new_type
.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the subtraction
rhs – The right-hand side of the subtraction
- Returns
A new instance of
new_type<BaseType, TagType, DerivationClause>
containing the result of applying-
to the objects contained bylhs
andrhs
.- Throws
Any exception thrown by the subtraction operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow subtractable andnew_type::base_type
is nothrow copy-constructible
- Enablement
This operator shall be available iff.
new_type::base_type
supports subtraction using-
andthe
derivation clause
containsArithmetic
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause> &operator-=
(new_type<BaseType, TagType, DerivationClause> &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Subtract two instances of the same
new_type
by overwriting the first one.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the subtraction
rhs – The right-hand side of the subtraction
- Returns
A reference to the first argument containing the value modified by applying
-=
to the objects contained bylhs
andrhs
.- Throws
Any exception thrown by the subtraction-assignment operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow subtract-assignable andnew_type::base_type
is nothrow copy-constructible
- Enablement
This operator shall be available iff.
new_type::base_type
supports subtraction using-=
andthe
derivation clause
containsArithmetic
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>operator*
(new_type<BaseType, TagType, DerivationClause> const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Multiply two instances of the same
new_type
.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the multiplication
rhs – The right-hand side of the multiplication
- Returns
A new instance of
new_type<BaseType, TagType, DerivationClause>
containing the result of applying*
to the objects contained bylhs
andrhs
.- Throws
Any exception thrown by the multiplication operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow multipliable andnew_type::base_type
is nothrow copy-constructible
- Enablement
This operator shall be available iff.
new_type::base_type
supports multiplication using*
andthe
derivation clause
containsArithmetic
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause> &operator*=
(new_type<BaseType, TagType, DerivationClause> &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Multiply two instances of the same
new_type
by overwriting the first one.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the multiplication
rhs – The right-hand side of the multiplication
- Returns
A reference to the first argument containing the value modified by applying
*=
to the objects contained bylhs
andrhs
.- Throws
Any exception thrown by the multiplication-assignment operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow multiply-assignable andnew_type::base_type
is nothrow copy-constructible
- Enablement
This operator shall be available iff.
new_type::base_type
supports multiplication using*=
andthe
derivation clause
containsArithmetic
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>operator/
(new_type<BaseType, TagType, DerivationClause> const &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Divide two instances of the same
new_type
.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the division
rhs – The right-hand side of the division
- Returns
A new instance of
new_type<BaseType, TagType, DerivationClause>
containing the result of applying/
to the objects contained bylhs
andrhs
.- Throws
Any exception thrown by the division operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow dividable andnew_type::base_type
is nothrow copy-constructible
- Enablement
This operator shall be available iff.
new_type::base_type
supports division using/
andthe
derivation clause
containsArithmetic
New in version 1.0.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause> &operator/=
(new_type<BaseType, TagType, DerivationClause> &lhs, new_type<BaseType, TagType, DerivationClause> const &rhs)¶ Divide two instances of the same
new_type
by overwriting the first one.- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
lhs – The left-hand side of the division
rhs – The right-hand side of the division
- Returns
A reference to the first argument containing the value modified by applying
/=
to the objects contained bylhs
andrhs
.- Throws
Any exception thrown by the division-assignment operator of the objects contained by
lhs
andrhs
. This operator shall be noexcept iff.new_type::base_type
is nothrow divide-assignable andnew_type::base_type
is nothrow copy-constructible
- Enablement
This operator shall be available iff.
new_type::base_type
supports division using/=
andthe
derivation clause
containsArithmetic
New in version 1.0.0.
Iterators¶
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::iteratorbegin
(new_type<BaseType, TagType, DerivationClause> &obj)¶ Get an iterator to the beginning of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator to the begining of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
derivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functionbegin(BaseType &)
that returns an instance of typenew_type::iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::const_iteratorbegin
(new_type<BaseType, TagType, DerivationClause> const &obj)¶ Get a constant iterator to the beginning of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator to the begining of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functionbegin(BaseType const &)
that returns an instance of typenew_type::const_iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::const_iteratorcbegin
(new_type<BaseType, TagType, DerivationClause> const &obj)¶ Get a constant iterator to the beginning of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator to the begining of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functioncbegin(BaseType const &)
that returns an instance of typenew_type::const_iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::reverse_iteratorrbegin
(new_type<BaseType, TagType, DerivationClause> &obj)¶ Get a reverse iterator to the beginning of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator to the begining of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
derivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functionrbegin(BaseType &)
that returns an instance of typenew_type::reverse_iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::const_reverse_iteratorrbegin
(new_type<BaseType, TagType, DerivationClause> const &obj)¶ Get a constant reverse iterator to the beginning of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator to the begining of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functionrbegin(BaseType const &)
that returns an instance of typenew_type::const_reverse_iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::const_reverse_iteratorcrbegin
(new_type<BaseType, TagType, DerivationClause> const &obj)¶ Get a constant reverse iterator to the beginning of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator to the begining of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functioncrbegin(BaseType const &)
that returns an instance of typenew_type::const_reverse_iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::iteratorend
(new_type<BaseType, TagType, DerivationClause> &obj)¶ Get an iterator beyond the end of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator beyond the end of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
derivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functionend(BaseType &)
that returns an instance of typenew_type::iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::const_iteratorend
(new_type<BaseType, TagType, DerivationClause> const &obj)¶ Get a constant iterator beyond the end of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator beyond the end of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functionend(BaseType const &)
that returns an instance of typenew_type::const_iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::const_iteratorcend
(new_type<BaseType, TagType, DerivationClause> const &obj)¶ Get a constant iterator beyond the end of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator beyond the end of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functioncend(BaseType const &)
that returns an instance of typenew_type::const_iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::reverse_iteratorrend
(new_type<BaseType, TagType, DerivationClause> &obj)¶ Get a reverse iterator beyond the end of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator beyond the end of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
derivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functionrend(BaseType &)
that returns an instance of typenew_type::reverse_iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::const_reverse_iteratorrend
(new_type<BaseType, TagType, DerivationClause> const &obj)¶ Get a constant reverse iterator beyond the end of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator beyond the end of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functionrend(BaseType const &)
that returns an instance of typenew_type::const_reverse_iterator
New in version 1.1.0.
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
constexpr new_type<BaseType, TagType, DerivationClause>::const_reverse_iteratorcrend
(new_type<BaseType, TagType, DerivationClause> const &obj)¶ Get a constant reverse iterator beyond the end of the object contained by an instance of
new_type
- Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
- Parameters
obj – The object to retrieve the iterator from
- Returns
An iterator beyond the end of the object of contained by
obj
.- Throws
Any exception
- Enablement
This function shall be available iff.
this
new_type
’sderivation clause
containsIterable
andfor the
new_type
’sbase type
exists a namespace-level functioncrend(BaseType const &)
that returns an instance of typenew_type::const_reverse_iterator
New in version 1.1.0.
std::hash
Support¶
-
template<typename
BaseType
, typenameTagType
, autoDerivationClause
>
classstd
::
hash
<nt::new_type<BaseType, TagType, DerivationClause>>¶ - Template Parameters
BaseType – The type of the contained object
TagType – A tag to uniquely identify an instance of
nt::new_type
DerivationClause – A (possibly empty) list of derivation tags as generated by
nt::deriving()
Hash an instance of
new_type
using the hash implementation of thebase type
.-
constexpr std::size
operator()
(nt::new_type<BaseType, TagType, DerivationClause> const &value) const¶ - Parameters
value – A
nt::new_type
value to be hashed- Returns
The result of applying
std::hash
to the object contained byvalue
- Throws
Any exception thrown by the call operator of the specialization of :cpp:class`std::hash` for the type of the object contained by
value
.- Enablement
This operator shall be available iff.
nt::new_type::base_type
is hashable andthe
derivation clause
containsHash
.
New in version 1.0.0.
Header <newtype/derivable.hpp>
¶
This header defines the alias template derivable
as well as the set of standard derivation tags.
Class template derivable
¶
-
template<typename
NameTag
>
classderivable
¶ - Template Parameters
NameTag – A tag uniquely identifing a specific derivation tag
New in version 1.0.0.
Standard derivation tags¶
-
auto constexpr
Arithmetic
= derivable<class arithmetic_tag>{}¶ This tag enables the derivation of the following arithmetic operators:
New in version 1.0.0.
-
auto constexpr
EqBase
= derivable<class eq_base_tag>{}¶ This tag enables the derivation of following “equality comparison with base type” operators:
By virtue of its nature, deriving this feature compromises the strength of the given
new_type
.New in version 1.0.0.
-
auto constexpr
ImplicitConversion
= derivable<class implicit_conversion_tag>{}¶ This tag enables the derivation of the implicit “conversion to base type” operator. By virtue of its nature, deriving this feature compromises the strength of the given
new_type
.New in version 1.0.0.
-
auto constexpr
Hash
= derivable<class hash_tag>{}¶ This tag enables the derivation of a specialization of
std::hash
New in version 1.0.0.
-
auto constexpr
Indirection
= derivable<class indirection_tag>{}¶ This tag enables the derivation of the “member access through pointer” operator
operator->()
(both inconst
and non-const
variants).New in version 1.0.0.
-
auto constexpr
Iterable
= derivable<class iterable_tag>{}¶ This tag enables the derivation of the following “standard iterator functions”:
New in version 1.1.0.
-
auto constexpr
Read
= derivable<class read_tag>{}¶ This tag enables the derivation of the “stream output”
operator<<(std::basic_ostream &, new_type const &)
New in version 1.0.0.
-
auto constexpr
Relational
= derivable<class relational_tag>{}¶ This tag enables the derivation of the following relational operators:
New in version 1.0.0.
-
auto constexpr
Show
= derivable<class show_tag>{}¶ This tag enables the derivation of the “stream input”
operator>>(std::basic_istream &, new_type &)
New in version 1.0.0.
Header <newtype/deriving.hpp>
¶
This header contains the definition of the function template deriving()
.
Function template deriving()
¶
-
template<typename ...
DerivableTags
>
constexpr derivation_clause<DerivableTags...>deriving
(derivable<DerivableTags>... features) noexcept¶ This function can be used to create a new
derivation_clause
for use in the definitions of instances ofnew_type
.New in version 1.0.0.
See also
Standard derivation tags for a list of standard derivation tags
Header <newtype/derivation_clause.hpp>
¶
This header contains the definition of the class template derivation_clause
Class template derivation_clause
¶
-
template<typename ...
DerivableTags
>
classderivation_clause
¶ Derivation clauses are used by
new_type
to allow users to specify a set of automatically derived support functions.- Template Parameters
DerivableTags – A (potentially empty) list of tag types identifying the contained derivations
New in version 1.0.0.
Constructors
-
constexpr
derivation_clause
(derivable<DerivableTags>...) noexcept¶ Construct a new derivations clause containing the given derivations
Evaluation Functions
-
template<typename
DerivableTag
>
constexpr booloperator()
(derivable<DerivableTag>) const noexcept¶ Check if this
derivation clause
contains the given derivation- Template Parameters
DerivableTag – A tag uniquely identifying a derivation
-
template<typename
DerivableTag
, typename ...RemainingDerivableTags
>
constexpr booloperator()
(derivable<DerivableTag>, derivable<RemainingDerivableTags>...) const noexcept¶ Check if this
derivation clause
contains all of the given derivations- Template Parameters
DerivableTag – A tag uniquely identifying a derivation
RemainingDerivableTags – A list of tags uniquely identifying a list of derivations
Equality Comparison Operators
-
template<typename ...
OtherDerivableTags
>
constexpr booloperator==
(derivation_clause<OtherDerivableTags...> other) const noexcept¶ Check if this
derivation clause
is identical to the one represented byother
. Two derivation clauses are considered equal iff. both contain the same derivations irrespective of their order.- Template Parameters
OtherDerivableTags – A (potentialy empty) list of tags uniquely identifying a list of derivations
- Parameters
other – An existing
derivation clause
-
template<typename ...
OtherDerivableTags
>
constexpr booloperator!=
(derivation_clause<OtherDerivableTags...> other) const noexcept¶ Check if this
derivation clause
is different from the one represented byother
. Two derivation clauses are considered different iff. one contains at least one derivation not contained by the other.- Template Parameters
OtherDerivableTags – A (potentialy empty) list of tags uniquely identifying a list of derivations
- Parameters
other – An existing
derivation clause
Relational Comparison Operators
-
template<typename ...
OtherDerivableTags
>
constexpr booloperator<
(derivation_clause<OtherDerivableTags...> other) const noexcept¶ Check if this
derivation clause
is a subset of the one represented byother
. Onederivation clause
is considered to be a subset of another iff. the list of derivations of this instance forms a proper subset of the list of derivations of the other.- Template Parameters
OtherDerivableTags – A (potentialy empty) list of tags uniquely identifying a list of derivations
- Parameters
other – An existing
derivation clause
-
template<typename ...
OtherDerivableTags
>
constexpr booloperator>
(derivation_clause<OtherDerivableTags...> other) const noexcept¶ Check if this
derivation clause
is a superset of the one represented byother
. Onederivation clause
is considered to be a superset of another iff. the list of derivations of this instance forms a proper superset of the list of derivations of the other.- Template Parameters
OtherDerivableTags – A (potentialy empty) list of tags uniquely identifying a list of derivations
- Parameters
other – An existing
derivation clause
-
template<typename ...
OtherDerivableTags
>
constexpr booloperator<=
(derivation_clause<OtherDerivableTags...> other) const noexcept¶ Check if this
derivation clause
is either identical to or a subset of the one represented byother
. Onederivation clause
is considered to be identical to another iff. the list of derivations of this instance is identical to the list of derivations of the other. Onederivation clause
is considered to be a subset of another iff. the list of derivations of this instance forms a proper subset of the list of derivations of the other.- Template Parameters
OtherDerivableTags – A (potentialy empty) list of tags uniquely identifying a list of derivations
- Parameters
other – An existing
derivation clause
-
template<typename ...
OtherDerivableTags
>
constexpr booloperator>=
(derivation_clause<OtherDerivableTags...> other) const noexcept¶ Check if this
derivation clause
is either identical to or a superset of the one represented byother
. Onederivation clause
is considered to be identical to another iff. the list of derivations of this instance is identical to the list of derivations of the other. Onederivation clause
is considered to be a superset of another iff. the list of derivations of this instance forms a proper superset of the list of derivations of the other.- Template Parameters
OtherDerivableTags – A (potentialy empty) list of tags uniquely identifying a list of derivations
- Parameters
other – An existing
derivation clause