General Utility Library for C++14  2.12
Classes | Functions
gul14/cat.h

Detailed Description

Concatenation of strings and other types.

Classes

class  gul14::ConvertingStringView
 A string view that can automatically convert numbers into strings. More...
 

Functions

std::string gul14::cat ()
 Efficiently concatenate an arbitrary number of strings and numbers. More...
 
std::string gul14::cat (const ConvertingStringView &s)
 
GUL_EXPORT std::string gul14::cat (const ConvertingStringView &s1, const ConvertingStringView &s2)
 
GUL_EXPORT std::string gul14::cat (const ConvertingStringView &s1, const ConvertingStringView &s2, const ConvertingStringView &s3)
 
GUL_EXPORT std::string gul14::cat (std::initializer_list< ConvertingStringView > pieces)
 
template<typename... Args, typename = std::enable_if_t<(sizeof...(Args) > 3)>>
std::string gul14::cat (const Args &... args)
 

Function Documentation

◆ cat() [1/6]

std::string gul14::cat ( )
inline

Efficiently concatenate an arbitrary number of strings and numbers.

Numbers are converted to strings in the same way as done by std::to_string. cat() reserves the correct amount of space before concatenating the strings and can therefore save several memory allocations compared to concatenation with "+".

std::string str = gul14::cat(13.5, std::string(" quick "), "brown foxes ", "jump over ",
42, " lazy dogs'", std::string(" heads."));
// str == "13.500000 quick brown foxes jump over 42 lazy dogs' heads."
std::string cat()
Efficiently concatenate an arbitrary number of strings and numbers.
Definition: cat.h:97
Returns
a string containing the concatenation of all arguments.

Referenced by gul14::SlidingBuffer< ElementT, fixed_capacity, Container >::at(), gul14::SmallVector< ElementT, in_capacity >::at(), and gul14::cat().

◆ cat() [2/6]

template<typename... Args, typename = std::enable_if_t<(sizeof...(Args) > 3)>>
std::string gul14::cat ( const Args &...  args)
inline
See also
cat()

References gul14::cat().

◆ cat() [3/6]

std::string gul14::cat ( const ConvertingStringView s)
inline
See also
cat()

◆ cat() [4/6]

std::string gul14::cat ( const ConvertingStringView s1,
const ConvertingStringView s2 
)

◆ cat() [5/6]

std::string gul14::cat ( const ConvertingStringView s1,
const ConvertingStringView s2,
const ConvertingStringView s3 
)

◆ cat() [6/6]

std::string gul14::cat ( std::initializer_list< ConvertingStringView pieces)
See also
cat()