Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add std::basic_string allocator support to StringRef, StringBuffer and relatives #441

Merged
merged 2 commits into from
Dec 26, 2016

Conversation

glebov-andrey
Copy link
Contributor

std::basic_string allocator support

Modified the constructors of BasicStringRef and BasicCStringRef to accept std::basic_strings with any allocator. Also modified and BasicWriter.str() to accept custom allocator parameter. This allows the following code to work:

using scalable_string = std::basic_string<char, std::char_traits<char>, scalable_allocator<char> >;
fmt::MemoryWriter writer;
writer << "Hello from " << scalable_string{"fmtlib"} << '\n';
const scalable_string result_str = writer.str<scalable_allocator<char> >();

Modified StringBuffer and BasicStringWriter to accept custom allocator template parameters for the internal string and the move_to parameter.

@glebov-andrey
Copy link
Contributor Author

Since there are no default template arguments in C++98, I reversed the functions BasicWriter::str() and BasicStringRef::to_string().
Also changed StringBuffer::StringType to conform to the Google C++ Code Style (was string_type).

@vitaut vitaut merged commit db780cb into fmtlib:master Dec 26, 2016
@vitaut
Copy link
Contributor

vitaut commented Dec 26, 2016

Merged, thanks!

@glebov-andrey glebov-andrey deleted the basic_string_allocator branch December 26, 2016 16:38
vitaut added a commit that referenced this pull request Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants