Build fixes
This commit is contained in:
parent
435133426e
commit
90219a772b
@ -11,13 +11,6 @@
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#if (defined(FMT_HAS_VARIANT) || __cplusplus >= 201703L)
|
||||
# include <variant>
|
||||
# ifndef FMT_HAS_VARIANT
|
||||
# define FMT_HAS_VARIANT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
namespace internal {
|
||||
@ -61,18 +54,23 @@ template <typename T, typename Context>
|
||||
using need_dyn_copy_t = typename need_dyn_copy<T, Context>::type;
|
||||
|
||||
class dyn_arg_storage {
|
||||
// Workaround clang's -Wweak-vtables. For templates (unlike regular classes
|
||||
// doesn't complain about inability to deduce translation unit to place vtable
|
||||
// So dyn_arg_node_base is made a fake template
|
||||
|
||||
template<typename = void>
|
||||
struct dyn_arg_node_base {
|
||||
virtual ~dyn_arg_node_base() = default;
|
||||
std::unique_ptr<dyn_arg_node_base> next_;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct dyn_arg_node : dyn_arg_node_base {
|
||||
struct dyn_arg_node : dyn_arg_node_base<> {
|
||||
T value_;
|
||||
FMT_CONSTEXPR explicit dyn_arg_node(T&& arg) : value_{arg}{}
|
||||
};
|
||||
|
||||
std::unique_ptr<dyn_arg_node_base> head_{nullptr};
|
||||
std::unique_ptr<dyn_arg_node_base<>> head_{nullptr};
|
||||
|
||||
public:
|
||||
dyn_arg_storage() = default;
|
||||
@ -84,8 +82,8 @@ public:
|
||||
|
||||
template<typename T>
|
||||
const T& emplace_front(T&& val) {
|
||||
auto node{new dyn_arg_node<T>{std::forward<T>(val)}};
|
||||
std::unique_ptr<dyn_arg_node_base> ptr{node};
|
||||
auto node = new dyn_arg_node<T>{std::forward<T>(val)};
|
||||
std::unique_ptr<dyn_arg_node_base<>> ptr{node};
|
||||
swap(ptr, head_);
|
||||
head_->next_ = std::move(ptr);
|
||||
return node->value_;
|
||||
|
||||
@ -31,18 +31,18 @@ TEST(FormatDynArgsTest, StringsAndRefs) {
|
||||
EXPECT_EQ("1234567890 and X234567890 and X234567890", result);
|
||||
}
|
||||
|
||||
struct Custom {
|
||||
struct custom_type {
|
||||
int i{0};
|
||||
};
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
template <> struct formatter<Custom> {
|
||||
template <> struct formatter<custom_type> {
|
||||
auto parse(format_parse_context& ctx) const -> decltype(ctx.begin()) {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const Custom& p, FormatContext& ctx) -> decltype(format_to(
|
||||
auto format(const custom_type& p, FormatContext& ctx) -> decltype(format_to(
|
||||
ctx.out(), std::declval<typename FormatContext::char_type const*>())) {
|
||||
return format_to(ctx.out(), "cust={}", p.i);
|
||||
}
|
||||
@ -50,8 +50,13 @@ template <> struct formatter<Custom> {
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
TEST(FormatDynArgsTest, CustomFormat) {
|
||||
using context = fmt::format_context;
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
Custom c{};
|
||||
static_assert(fmt::internal::need_dyn_copy_t<custom_type, context>::value, "");
|
||||
static_assert(
|
||||
fmt::internal::mapped_type_constant<custom_type, context>::value ==
|
||||
fmt::internal::type::custom_type, "");
|
||||
custom_type c{};
|
||||
store.push_back(c);
|
||||
++c.i;
|
||||
store.push_back(c);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user