commons 0.1.5
Header-only C++23 library of common/shared types for the C++ libraries
Loading...
Searching...
No Matches
comms::Id< Tag, Repr > Class Template Reference

Strong-typed identifier: a Repr value tagged with a phantom Tag. More...

#include <id.hpp>

Public Member Functions

 Id ()=delete
 Default-construct the underlying Repr when it is itself default-initializable; otherwise the constructor is deleted (the constrained-defaulted pattern keeps Id usable in containers that require value-initialization).
 
template<class U >
requires std::constructible_from<Repr, U&&> && (!std::is_same_v<std::remove_cvref_t<U>, Id>)
 Id (U &&u)
 Forward into the underlying Repr.
 
 Id (std::string_view sv)
 Convenience for StringId<Tag>: build directly from a string_view.
 

Detailed Description

template<class Tag, AllowedIdRepr Repr>
class comms::Id< Tag, Repr >

Strong-typed identifier: a Repr value tagged with a phantom Tag.

Two Ids with different tags are unrelated types even when the underlying representation is identical.

Constructor & Destructor Documentation

◆ Id()

template<class Tag , AllowedIdRepr Repr>
template<class U >
requires std::constructible_from<Repr, U&&> && (!std::is_same_v<std::remove_cvref_t<U>, Id>)
comms::Id< Tag, Repr >::Id ( U &&  u)
inlineexplicit

Forward into the underlying Repr.

Explicit so that an Id is never silently constructed from a raw value.


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