- removed templated str() and to_string() function

- code style fixes
This commit is contained in:
Andrey Glebov 2016-12-26 17:02:55 +03:00
parent 240e9175bd
commit fd2b9741c3
2 changed files with 10 additions and 16 deletions

View File

@ -494,14 +494,11 @@ class BasicStringRef {
/**
\rst
Converts a string reference to a ``std::basic_string`` object.
Converts a string reference to an ``std::string`` object.
\endrst
*/
template <typename Allocator = std::allocator<Char> >
std::basic_string<Char, std::char_traits<Char>, Allocator>
to_string(const Allocator &allocator = Allocator()) const {
return std::basic_string<Char, std::char_traits<Char>, Allocator>(
data_, size_, allocator);
std::basic_string<Char> to_string() const {
return std::basic_string<Char>(data_, size_);
}
/** Returns a pointer to the string data. */
@ -2576,14 +2573,11 @@ class BasicWriter {
/**
\rst
Returns the content of the output buffer as a `std::basic_string`.
Returns the content of the output buffer as an `std::string`.
\endrst
*/
template <typename Allocator = std::allocator<Char> >
std::basic_string<Char, std::char_traits<Char>, Allocator> str(
const Allocator &allocator = Allocator()) const {
return std::basic_string<Char, std::char_traits<Char>, Allocator>(
&buffer_[0], buffer_.size(), allocator);
std::basic_string<Char> str() const {
return std::basic_string<Char>(&buffer_[0], buffer_.size());
}
/**

View File

@ -20,10 +20,10 @@ namespace internal {
template <typename Char, typename Allocator = std::allocator<Char> >
class StringBuffer : public Buffer<Char> {
public:
typedef std::basic_string<Char, std::char_traits<Char>, Allocator> string_type;
typedef std::basic_string<Char, std::char_traits<Char>, Allocator> StringType;
private:
string_type data_;
StringType data_;
protected:
virtual void grow(std::size_t size) FMT_OVERRIDE {
@ -37,7 +37,7 @@ class StringBuffer : public Buffer<Char> {
: data_(allocator) {}
// Moves the data to ``str`` clearing the buffer.
void move_to(string_type &str) {
void move_to(StringType &str) {
data_.resize(this->size_);
str.swap(data_);
this->capacity_ = this->size_ = 0;
@ -49,7 +49,7 @@ class StringBuffer : public Buffer<Char> {
/**
\rst
This class template provides operations for formatting and writing data
into a character stream. The output is stored in ``std::basic_string``
into a character stream. The output is stored in a ``std::basic_string``
that grows dynamically.
You can use one of the following typedefs for common character types