ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Methods | List of all members
T_Append< TAppendable, TChar, TEnableIf > Struct Template Reference

#include <astring.hpp>

Class Description

template<typename TAppendable, typename TChar = aworx::lib::characters::character, typename TEnableIf = void>
struct aworx::lib::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).

Note
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 aworx::lib::strings::APPENDABLES.

Reference Documentation

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

Definition at line 91 of file astring.hpp.

Public Methods

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

Member Function Documentation

◆ operator()()

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.

Parameters
targetThe target string.
srcThe source object.

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