PlayRho  2.0.0
An interactive physics engine & library.
playrho::detail::IndexingNamedType< T, Tag > Class Template Reference

An indexable, hashable, named "strong type" template class. More...

#include <playrho/detail/IndexingNamedType.hpp>

Inheritance diagram for playrho::detail::IndexingNamedType< T, Tag >:
[legend]

Public Types

using underlying_type = T
 Underlying type alias.
 

Public Member Functions

constexpr IndexingNamedType () noexcept(std::is_nothrow_default_constructible_v< underlying_type >)
 Default constructor. More...
 
constexpr IndexingNamedType (const underlying_type &value) noexcept(std::is_nothrow_copy_constructible_v< underlying_type >)
 Copy initializing constructor.
 
constexpr IndexingNamedType (underlying_type &&value) noexcept(std::is_nothrow_move_constructible_v< underlying_type >)
 Move initializing constructor.
 
constexpr underlying_type const & get () const noexcept
 Accesses the underlying value.
 
constexpr underlying_typeget () noexcept
 Accesses the underlying value.
 
constexpr operator const underlying_type & () const noexcept
 Underlying type cast operator support.
 
constexpr operator underlying_type & () noexcept
 Underlying type cast operator support.
 

Friends

::std::size_t hash (const IndexingNamedType &v) noexcept
 Hashes the value given.
 
constexpr friend bool operator!= (const IndexingNamedType &lhs, const IndexingNamedType &rhs)
 Inequality operator.
 
constexpr friend bool operator< (const IndexingNamedType &lhs, const IndexingNamedType &rhs)
 Less-than operator.
 
constexpr friend bool operator<= (const IndexingNamedType &lhs, const IndexingNamedType &rhs)
 Less-than-or-equal-to operator.
 
constexpr friend bool operator== (const IndexingNamedType &lhs, const IndexingNamedType &rhs)
 Equality operator.
 
constexpr friend bool operator> (const IndexingNamedType &lhs, const IndexingNamedType &rhs)
 Greater-than operator.
 
constexpr friend bool operator>= (const IndexingNamedType &lhs, const IndexingNamedType &rhs)
 Greater-than-or-equal-to operator.
 
void swap (IndexingNamedType &a, IndexingNamedType &b) noexcept
 Swap function.
 

Related Functions

(Note that these are not member functions.)

template<typename T , typename Tag >
constexpr const T & UnderlyingValue (const IndexingNamedType< T, Tag > &o) noexcept
 Gets the underlying value.
 
template<typename T , typename Tag >
constexpr T & UnderlyingValue (IndexingNamedType< T, Tag > &o) noexcept
 Gets the underlying value.
 

Detailed Description

template<typename T, typename Tag>
class playrho::detail::IndexingNamedType< T, Tag >

An indexable, hashable, named "strong type" template class.

A template class for wrapping types into more special-purposed types. Wrapping types this way is often referred to as more "strongly typing" the underlying type.

Note
This comes from pulling together code found from various sites on the Internet.
See also
https://www.fluentcpp.com/2016/12/08/strong-types-for-strong-interfaces/
https://foonathan.net/blog/2016/10/19/strong-typedefs.html

Constructor & Destructor Documentation

◆ IndexingNamedType()

template<typename T , typename Tag >
constexpr playrho::detail::IndexingNamedType< T, Tag >::IndexingNamedType ( )
inlineconstexprnoexcept

Default constructor.

Note
This causes default initialization of the underlying type.

The documentation for this class was generated from the following file: