PlayRho  1.1.0
An Interactive Real-Time-Oriented C++ Physics Engine & Library
playrho::detail::IndexingNamedType< T, Tag > Class Template Reference

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

#include <IndexingNamedType.hpp>

Inheritance diagram for playrho::detail::IndexingNamedType< T, Tag >:
[legend]
Collaboration 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< underlying_type >::value)
 Default constructor. More...
 
constexpr IndexingNamedType (const underlying_type &value) noexcept(std::is_nothrow_copy_constructible< underlying_type >::value)
 Copy initializing constructor.
 
constexpr IndexingNamedType (underlying_type &&value) noexcept(std::is_nothrow_move_constructible< underlying_type >::value)
 Move initializing constructor.
 
constexpr operator underlying_type & () noexcept
 Underlying type cast operator support.
 
constexpr operator const underlying_type & () const noexcept
 Underlying type cast operator support.
 
constexpr underlying_typeget () noexcept
 Accesses the underlying value.
 
constexpr underlying_type const & get () const noexcept
 Accesses the underlying value.
 

Private Attributes

underlying_type value_
 Underlying value.
 

Friends

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

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 ( )
inlineexplicitconstexprnoexcept

Default constructor.

Note
This causes default initialization of the underlying type.

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