OpenTTD Source 20250311-master-g40ddc03423
StrongType::Typedef< TBaseType, TTag, TProperties > Struct Template Reference

Templated helper to make a type-safe 'typedef' representing a single POD value. More...

#include <strong_typedef_type.hpp>

Inheritance diagram for StrongType::Typedef< TBaseType, TTag, TProperties >:

Public Types

using BaseType = TBaseType
 

Public Member Functions

constexpr Typedef (const Typedef &)=default
 
constexpr Typedef (Typedef &&)=default
 
constexpr Typedef (const TBaseType &value)
 
constexpr Typedefoperator= (const Typedef &rhs)
 
constexpr Typedefoperator= (Typedef &&rhs)
 
constexpr TBaseType base () const noexcept
 

Data Fields

TBaseType value {}
 

Friends

struct Compare
 
struct Integer
 
template<typename TCompatibleType >
struct Compatible
 GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
 

Detailed Description

template<typename TBaseType, typename TTag, typename... TProperties>
struct StrongType::Typedef< TBaseType, TTag, TProperties >

Templated helper to make a type-safe 'typedef' representing a single POD value.

A normal 'typedef' is not distinct from its base type and will be treated as identical in many contexts. This class provides a distinct type that can still be assigned from and compared to values of its base type.

Example usage:

using MyType = StrongType::Typedef<int, struct MyTypeTag, StrongType::Compare, StrongType::Integer>;

Template Parameters
TBaseTypeType of the derived class (i.e. the concrete usage of this class).
TTagAn unique struct to keep types of the same TBaseType distinct.
TPropertiesA list of mixins to add to the class.

Definition at line 130 of file strong_typedef_type.hpp.

Member Typedef Documentation

◆ BaseType

template<typename TBaseType , typename TTag , typename... TProperties>
using StrongType::Typedef< TBaseType, TTag, TProperties >::BaseType = TBaseType

Definition at line 131 of file strong_typedef_type.hpp.

Constructor & Destructor Documentation

◆ Typedef()

template<typename TBaseType , typename TTag , typename... TProperties>
constexpr StrongType::Typedef< TBaseType, TTag, TProperties >::Typedef ( const TBaseType &  value)
inlineexplicitconstexpr

Definition at line 137 of file strong_typedef_type.hpp.

Member Function Documentation

◆ base()

template<typename TBaseType , typename TTag , typename... TProperties>
constexpr TBaseType StrongType::Typedef< TBaseType, TTag, TProperties >::base ( ) const
inlineconstexprnoexcept

Definition at line 143 of file strong_typedef_type.hpp.

◆ operator=() [1/2]

template<typename TBaseType , typename TTag , typename... TProperties>
constexpr Typedef & StrongType::Typedef< TBaseType, TTag, TProperties >::operator= ( const Typedef< TBaseType, TTag, TProperties > &  rhs)
inlineconstexpr

Definition at line 139 of file strong_typedef_type.hpp.

◆ operator=() [2/2]

template<typename TBaseType , typename TTag , typename... TProperties>
constexpr Typedef & StrongType::Typedef< TBaseType, TTag, TProperties >::operator= ( Typedef< TBaseType, TTag, TProperties > &&  rhs)
inlineconstexpr

Definition at line 140 of file strong_typedef_type.hpp.

Friends And Related Symbol Documentation

◆ Compare

template<typename TBaseType , typename TTag , typename... TProperties>
friend struct Compare
friend

Definition at line 146 of file strong_typedef_type.hpp.

◆ Compatible

template<typename TBaseType , typename TTag , typename... TProperties>
template<typename TCompatibleType >
friend struct Compatible
friend

GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)

Definition at line 148 of file strong_typedef_type.hpp.

◆ Integer

template<typename TBaseType , typename TTag , typename... TProperties>
friend struct Integer
friend

Definition at line 147 of file strong_typedef_type.hpp.

Field Documentation

◆ value

template<typename TBaseType , typename TTag , typename... TProperties>
TBaseType StrongType::Typedef< TBaseType, TTag, TProperties >::value {}

Definition at line 157 of file strong_typedef_type.hpp.


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