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

View File

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