Skip to content
DryPerspective edited this page Sep 28, 2023 · 1 revision

A header containing the conversion functions (and some others) added to the <string> header in C++11 and up - specifically the functions to convert from std::string types to and from arithmetic types.

This header also includes member functions added to std::string by DR (as free functions), as libstdc++ disables these in C++98 mode.

Features

erase
erase_if
Performs the erase-remove idiom to erase certain contents from a string
stoi
stol
Converts a std::string or std::wstring to a signed integer value
stoul Converts a std::string or std::wstring to an unsigned long
stof
stod
stold
Converts a std::string or std::wstring to a floating point value
to_string Converts a numerical value to a std::string.
to_wstring Converts a numerical value to a std::wstring.
front Returns the first character of a string.
back Returns the last character of a string.
pop_back Removes the last character from a string.
cbegin Returns a const iterator to the beginning of a string
cend Returns a const iterator to the beginning of a string
crbegin Returns a const reverse iterator to the beginning of the string
crend Returns a const reverse iterator to the end of a string

Sample Code

#include <iostream>
#include "cpp98/string.h"

int main(){
    std::cout << dp::to_string(123.456) << '\n';
}

Clone this wiki locally