ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
No Matches
T_Append< TAppendable, TChar, TEnableIf > Struct Template Reference


template<typename TAppendable, typename TChar = alib::characters::character, typename TEnableIf = void>
struct alib::strings::T_Append< TAppendable, TChar, TEnableIf >

This is a type-traits functor that allows to make custom types "appendable" to objects of type AString.

Specializations of this struct have to implement operator() , which is invoked by method AString::Append , when an instance of the type in question is passed.

For user defined string types that get adopted to ALib string system using a specialization of struct T_CharArray , no specialization of this functor is needed, because method AString::Append will accept such types likewise.

The third template parameter of this struct, TEnableIf , may be used to perform templated specializations based on a condition evaluated with std::enable_if (or similar TMP mechanics).

This struct is called a "functor" because its single member is operator() . This is different to other type-traits structs defined by ALib , which demand to implement one or more static methods with specializations. As operator() must not be static, the internal call to this operator is done by creating a temporary object of this "functor struct" and calling the operator on that.
The result in respect to the generated code is with both approaches the same. Using a functor here, is just a design decision.
See also
For details consult chapter 5.1 Appending Custom Types of the Programmer's Manual of module ALib Strings .
The documentation of built-in specializations for ALib types are collected in sub-namespace alib::strings::APPENDABLES.

Reference Documentation

Template Parameters
TAppendableThe type that should be made compatible with method TAString::Append .
TCharThe character type of the target AString. Defaults to character .
TEnableIfOptional TMP parameter to allow templated specializations.

Definition at line 95 of file astring.hpp.

#include <astring.hpp>

Public Method Index:

void operator() (TAString< TChar > &target, const TAppendable &src)

Method Details:

◆ operator()()

template<typename TAppendable , typename TChar = alib::characters::character, typename TEnableIf = void>
template ALIB_API void operator() ( TAString< TChar > & target,
const TAppendable & src )

This operator is invoked on a temporary object of this type by AString::Append , when an object of type TAppendable is passed.

Usually, specializations of this operator append a string representation of src to target . Special "appendable types" might modify target in other, arbitrary ways.

targetThe target string.
srcThe source object.

Definition at line 118 of file appendables.cpp.

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