The strong typedef class and helper macros.
Strong typedefs are especially helpful to distinguish function parameters at the type level. Consider the following function:
Even with parameter names in the function's declaration, the interface is easy to misuse. For example, the following code will compile (possibly without any warnings):
Instead, we introduce strong typedefs for the parameters.
Strong typedef wraps almost all operators, which are found in their respective headers.
When declaring two strong typedefs with the same underlying type, two distinct types need to be created:
|
template<typename Tag , typename Type > |
fcppt::strong_typedef< std::remove_cvref_t< Type >, Tag > | fcppt::make_strong_typedef (Type &&_value) |
| Creates a new strong typedef given a tag and a value.
|
|
template<typename StrongTypedef1 , typename Function , typename... StrongTypedefs> |
auto | fcppt::strong_typedef_apply (Function const &_function, StrongTypedef1 &&_strong_typedef1, StrongTypedefs &&..._strong_typedefs) -> fcppt::strong_typedef< decltype(_function(fcppt::move_if_rvalue< StrongTypedef1 >(_strong_typedef1.get()), fcppt::move_if_rvalue< StrongTypedefs >(_strong_typedefs.get())...)), fcppt::strong_typedef_tag< std::remove_cvref_t< StrongTypedef1 > > > |
| Applies a function to multiple strong typedefs.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > | fcppt::operator+ (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Add two strong typedefs.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > | fcppt::operator- (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Subtract two strong typedefs.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > | fcppt::operator* (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Multiply two strong typedefs.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > | fcppt::operator- (fcppt::strong_typedef< T, Tag > const &_value) |
| Unary minus.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > & | fcppt::operator++ (fcppt::strong_typedef< T, Tag > &_value) |
| Preincrement operator.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > & | fcppt::operator-- (fcppt::strong_typedef< T, Tag > &_value) |
| Predecrement operator.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > | fcppt::operator++ (fcppt::strong_typedef< T, Tag > &_value, int) |
| Postincrement operator.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > | fcppt::operator-- (fcppt::strong_typedef< T, Tag > &_value, int) |
| Postdecrement operator.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > & | fcppt::operator+= (fcppt::strong_typedef< T, Tag > &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Add and assign operator.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > & | fcppt::operator-= (fcppt::strong_typedef< T, Tag > &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Subtract and assign operator.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > & | fcppt::operator*= (fcppt::strong_typedef< T, Tag > &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Multiply and assign operator.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > & | fcppt::operator&= (fcppt::strong_typedef< T, Tag > &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Bitwise and and assign operator.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > & | fcppt::operator|= (fcppt::strong_typedef< T, Tag > &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Bitwise or and assign operator.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > & | fcppt::operator^= (fcppt::strong_typedef< T, Tag > &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Bitwise xor and assign operator.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > | fcppt::operator& (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Bitwise and.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > | fcppt::operator| (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Bitwise or.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > | fcppt::operator^ (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Bitwise xor.
|
|
template<typename T , typename Tag > |
fcppt::strong_typedef< T, Tag > | fcppt::operator~ (fcppt::strong_typedef< T, Tag > const &_value) |
| Bitwise negation.
|
|
template<typename T , typename Tag > |
bool | fcppt::operator< (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Operator less.
|
|
template<typename T , typename Tag > |
bool | fcppt::operator<= (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Operator less equal.
|
|
template<typename T , typename Tag > |
bool | fcppt::operator> (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Operator greater.
|
|
template<typename T , typename Tag > |
bool | fcppt::operator>= (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Operator greater equal.
|
|
template<typename T , typename Tag > |
bool | fcppt::operator== (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Operator equal.
|
|
template<typename T , typename Tag > |
bool | fcppt::operator!= (fcppt::strong_typedef< T, Tag > const &_left, fcppt::strong_typedef< T, Tag > const &_right) |
| Operator not equal.
|
|
template<typename StrongTypedef , typename Conv , typename Arg >
requires fcppt::is_strong_typedef<StrongTypedef>::value |
constexpr StrongTypedef | fcppt::strong_typedef_construct_cast (Arg const &_arg) |
| Applies a cast from fcppt.cast and then construct the strong typedef.
|
|
template<typename Ch , typename Traits , typename T , typename Tag > |
std::basic_istream< Ch, Traits > & | fcppt::operator>> (std::basic_istream< Ch, Traits > &_stream, fcppt::strong_typedef< T, Tag > &_value) |
| Input operator for strong typedefs.
|
|
template<typename StrongTypedef , typename Function > |
auto | fcppt::strong_typedef_map (StrongTypedef &&_input, Function const &_function) -> fcppt::strong_typedef< decltype(_function(fcppt::move_if_rvalue< StrongTypedef >(_input.get()))), fcppt::strong_typedef_tag< std::remove_cvref_t< StrongTypedef > > > |
| Maps over a strong typedef.
|
|
template<typename Ch , typename Traits , typename T , typename Tag > |
std::basic_ostream< Ch, Traits > & | fcppt::operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::strong_typedef< T, Tag > const &_value) |
| Output operator for strong typedefs.
|
|