25template <
typename T>
const T&
unwrap(
const T& v) {
return v; }
26template <
typename T>
const T&
unwrap(
const std::reference_wrapper<T>& v) {
27 return static_cast<const T&
>(v);
34 template <
typename =
void>
struct node {
35 virtual ~node() =
default;
36 std::unique_ptr<node<>> next;
39 template <
typename T>
struct typed_node : node<> {
42 template <
typename Arg>
45 template <
typename Char>
50 std::unique_ptr<node<>> head_;
53 template <
typename T,
typename Arg>
const T&
push(
const Arg&
arg) {
54 auto new_node = std::unique_ptr<typed_node<T>>(
new typed_node<T>(
arg));
56 new_node->next = std::move(head_);
57 head_ = std::move(new_node);
73template <
typename Context>
81 using char_type =
typename Context::char_type;
83 template <
typename T>
struct need_copy {
89 std::is_same<T, basic_string_view<char_type>>::value ||
90 std::is_same<T, detail::std_string_view<char_type>>::value ||
99 std::is_convertible<T, std::basic_string<char_type>>::value &&
101 std::basic_string<char_type>, T>;
104 std::vector<basic_format_arg<Context>> data_;
105 std::vector<detail::named_arg_info<char_type>> named_info_;
113 unsigned long long get_types()
const {
121 return named_info_.empty() ? data_.data() : data_.data() + 1;
124 template <
typename T>
void emplace_arg(
const T&
arg) {
125 data_.emplace_back(detail::make_arg<Context>(
arg));
128 template <
typename T>
130 if (named_info_.empty()) {
132 data_.insert(data_.begin(), {zero_ptr, 0});
135 auto pop_one = [](std::vector<basic_format_arg<Context>>* data) {
138 std::unique_ptr<std::vector<basic_format_arg<Context>>,
decltype(pop_one)>
139 guard{&data_, pop_one};
140 named_info_.push_back({
arg.name,
static_cast<int>(data_.size() - 2u)});
141 data_[0].value_.named_args = {named_info_.data(), named_info_.size()};
167 emplace_arg(dynamic_args_.
push<stored_type<T>>(
arg));
190 "objects of built-in types and string views are always copied");
191 emplace_arg(
arg.get());
199 template <
typename T>
201 const char_type* arg_name =
202 dynamic_args_.
push<std::basic_string<char_type>>(
arg.name).c_str();
224 void reserve(
size_t new_cap,
size_t new_cap_named) {
226 "Set of arguments includes set of named arguments");
227 data_.reserve(new_cap);
228 named_info_.reserve(new_cap_named);
you may not use this file except in compliance with the License You may obtain a copy of the License at software distributed under the License is distributed on an AS IS WITHOUT WARRANTIES OR CONDITIONS OF ANY either express or implied See the License for the specific language governing permissions and limitations under the License LLVM Exceptions to the Apache License As an if
Definition: ThirdPartyNotices.txt:289
An implementation of std::basic_string_view for pre-C++17.
Definition: core.h:398
const T & push(const Arg &arg)
Definition: args.h:53
constexpr FMT_INLINE value()
Definition: core.h:1261
#define FMT_ASSERT(condition, message)
Definition: core.h:336
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
\rst Returns a named argument to be used in a formatting function.
Definition: core.h:1841
#define FMT_GCC_VERSION
Definition: core.h:33
#define FMT_CONSTEXPR
Definition: core.h:105
#define FMT_BEGIN_NAMESPACE
Definition: core.h:174
typename std::conditional< B, T, F >::type conditional_t
Definition: core.h:258
#define FMT_END_NAMESPACE
Definition: core.h:177
detail namespace with internal helper functions
Definition: xchar.h:20
const T & unwrap(const T &v)
Definition: args.h:25
@ has_named_args_bit
Definition: core.h:1485
@ is_unpacked_bit
Definition: core.h:1484
type
Definition: core.h:556
constexpr FMT_INLINE auto const_check(T value) -> T
Definition: core.h:323