Skip to content

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