forked from fmtlib/fmt
Fixed issue #779
This commit is contained in:
@ -237,8 +237,8 @@ class basic_string_view {
|
|||||||
FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(FMT_NULL), size_(0) {}
|
FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(FMT_NULL), size_(0) {}
|
||||||
|
|
||||||
/** Constructs a string reference object from a C string and a size. */
|
/** Constructs a string reference object from a C string and a size. */
|
||||||
FMT_CONSTEXPR basic_string_view(const Char *s, size_t size) FMT_NOEXCEPT
|
FMT_CONSTEXPR basic_string_view(const Char *s, size_t count) FMT_NOEXCEPT
|
||||||
: data_(s), size_(size) {}
|
: data_(s), size_(count) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
@ -274,8 +274,8 @@ class basic_string_view {
|
|||||||
|
|
||||||
// Lexicographically compare this string reference to other.
|
// Lexicographically compare this string reference to other.
|
||||||
int compare(basic_string_view other) const {
|
int compare(basic_string_view other) const {
|
||||||
size_t size = size_ < other.size_ ? size_ : other.size_;
|
size_t str_size = size_ < other.size_ ? size_ : other.size_;
|
||||||
int result = std::char_traits<Char>::compare(data_, other.data_, size);
|
int result = std::char_traits<Char>::compare(data_, other.data_, str_size);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1);
|
result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1);
|
||||||
return result;
|
return result;
|
||||||
@ -327,13 +327,13 @@ class basic_buffer {
|
|||||||
std::size_t capacity_;
|
std::size_t capacity_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
basic_buffer(T *p = FMT_NULL, std::size_t size = 0, std::size_t capacity = 0)
|
basic_buffer(T *p = FMT_NULL, std::size_t buf_size = 0, std::size_t buf_capacity = 0)
|
||||||
FMT_NOEXCEPT: ptr_(p), size_(size), capacity_(capacity) {}
|
FMT_NOEXCEPT: ptr_(p), size_(buf_size), capacity_(buf_capacity) {}
|
||||||
|
|
||||||
/** Sets the buffer data and capacity. */
|
/** Sets the buffer data and capacity. */
|
||||||
void set(T *data, std::size_t capacity) FMT_NOEXCEPT {
|
void set(T *buf_data, std::size_t buf_capacity) FMT_NOEXCEPT {
|
||||||
ptr_ = data;
|
ptr_ = buf_data;
|
||||||
capacity_ = capacity;
|
capacity_ = buf_capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Increases the buffer capacity to hold at least *capacity* elements. */
|
/** Increases the buffer capacity to hold at least *capacity* elements. */
|
||||||
@ -369,9 +369,9 @@ class basic_buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Reserves space to store at least *capacity* elements. */
|
/** Reserves space to store at least *capacity* elements. */
|
||||||
void reserve(std::size_t capacity) {
|
void reserve(std::size_t new_capacity) {
|
||||||
if (capacity > capacity_)
|
if (new_capacity > capacity_)
|
||||||
grow(capacity);
|
grow(new_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_back(const T &value) {
|
void push_back(const T &value) {
|
||||||
@ -828,8 +828,8 @@ class context_base {
|
|||||||
typedef basic_format_arg<Context> format_arg;
|
typedef basic_format_arg<Context> format_arg;
|
||||||
|
|
||||||
context_base(OutputIt out, basic_string_view<char_type> format_str,
|
context_base(OutputIt out, basic_string_view<char_type> format_str,
|
||||||
basic_format_args<Context> args)
|
basic_format_args<Context> ctx_args)
|
||||||
: parse_context_(format_str), out_(out), args_(args) {}
|
: parse_context_(format_str), out_(out), args_(ctx_args) {}
|
||||||
|
|
||||||
// Returns the argument with specified index.
|
// Returns the argument with specified index.
|
||||||
format_arg do_get_arg(unsigned arg_id) {
|
format_arg do_get_arg(unsigned arg_id) {
|
||||||
@ -909,8 +909,8 @@ class basic_format_context :
|
|||||||
stored in the object so make sure they have appropriate lifetimes.
|
stored in the object so make sure they have appropriate lifetimes.
|
||||||
*/
|
*/
|
||||||
basic_format_context(OutputIt out, basic_string_view<char_type> format_str,
|
basic_format_context(OutputIt out, basic_string_view<char_type> format_str,
|
||||||
basic_format_args<basic_format_context> args)
|
basic_format_args<basic_format_context> ctx_args)
|
||||||
: base(out, format_str, args) {}
|
: base(out, format_str, ctx_args) {}
|
||||||
|
|
||||||
format_arg next_arg() {
|
format_arg next_arg() {
|
||||||
return this->do_get_arg(this->parse_context().next_arg_id());
|
return this->do_get_arg(this->parse_context().next_arg_id());
|
||||||
|
Reference in New Issue
Block a user