CPP-AP 2.2.6
Command-line argument parser for C++20
Loading...
Searching...
No Matches
str_utility.hpp File Reference

Provides common string utility functions. More...

#include "concepts.hpp"
#include <sstream>
#include <string_view>

Go to the source code of this file.

Functions

template<c_writable T>
std::string ap::detail::as_string (const T &value) noexcept
 Converts a value to std::string.
 
template<std::ranges::range R>
requires (c_writable<std::ranges::range_value_t<R>>)
std::string ap::detail::join (const R &range, const std::string_view delimiter=", ")
 Joins elements of a range into a single string with a delimiter.
 

Detailed Description

Provides common string utility functions.

Definition in file str_utility.hpp.

Function Documentation

◆ as_string()

template<c_writable T>
std::string ap::detail::as_string ( const T &  value)
noexcept

Converts a value to std::string.

Template Parameters
TThe value type (must satisfy the ap::detail::c_writable concept).
Parameters
valueThe value to convert.

Definition at line 25 of file str_utility.hpp.

◆ join()

template<std::ranges::range R>
requires (c_writable<std::ranges::range_value_t<R>>)
std::string ap::detail::join ( const R &  range,
const std::string_view  delimiter = ", " 
)

Joins elements of a range into a single string with a delimiter.

Template Parameters
RThe type of the value range. The value type of R must satisfy the c_writable concept.
Parameters
rangeThe input range to join.
delimiterThe separator string to insert between elements.
Returns
A single string with all elements joined by the delimiter.
Todo:
Replace with std::views::join after transition to C++23.

Definition at line 41 of file str_utility.hpp.