Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Scine::Molassembler::Temple::StrongIndex< Tag, T > Class Template Reference

Type helper for creating strong index types that are type-level distinct from their fundamental types. More...

#include <StrongIndex.h>

Inheritance diagram for Scine::Molassembler::Temple::StrongIndex< Tag, T >:

Public Types

using value_type = T
 
using Hash = boost::hash< StrongIndex< Tag, T >>
 

Public Member Functions

constexpr StrongIndex ()=default
 Default constructor does not value initialize.
 
constexpr StrongIndex (T v)
 Explicit value initialization.
 
constexpr StrongIndex (const StrongIndex &other)=default
 
constexpr StrongIndex (StrongIndex &&other) noexcept=default
 
constexpr StrongIndexoperator= (const StrongIndex &other)=default
 
constexpr StrongIndexoperator= (StrongIndex &&other) noexcept=default
 
constexpr StrongIndexoperator= (const T &v)
 Assignment from fundamental base type.
 
constexpr operator T & () noexcept
 
constexpr operator const T & () const noexcept
 
constexpr auto tie () const
 
- Public Member Functions inherited from Scine::Molassembler::Temple::Crtp::LexicographicComparable< StrongIndex< Tag, T > >
constexpr bool operator== (const LexicographicComparable &other) const
 
constexpr bool operator!= (const LexicographicComparable &other) const
 
constexpr bool operator< (const LexicographicComparable &other) const
 
constexpr bool operator<= (const LexicographicComparable &other) const
 
constexpr bool operator> (const LexicographicComparable &other) const
 
constexpr bool operator>= (const LexicographicComparable &other) const
 

Private Attributes

v_
 

Additional Inherited Members

- Static Public Member Functions inherited from Scine::Molassembler::Temple::Crtp::LexicographicComparable< StrongIndex< Tag, T > >
static constexpr const
StrongIndex< Tag, T > & 
derived (const LexicographicComparable &base)
 

Detailed Description

template<typename Tag, typename T>
class Scine::Molassembler::Temple::StrongIndex< Tag, T >

Type helper for creating strong index types that are type-level distinct from their fundamental types.

Template Parameters
TagDistinct tag type for each distinct 'type' of tag to avoid interconvertibility
TFundamental type of the index

Example: Defining a new strong index type

struct foo_tag;
using Foo = StrongIndex<foo_tag, unsigned>;
Foo foo(4);
Note
This "strong" index type isn't yet as strong as it could be... Implicit base conversion operators aren't great.

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