Skip to content

Commit

Permalink
Disable constexpr fmt::formatted_size on Visual Studio 2019
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Shchapov <[email protected]>
  • Loading branch information
phprus committed Aug 3, 2024
1 parent 523c374 commit 67eb7ed
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ template <typename T> class buffer {
// Workaround for Visual Studio 2019 to fix error C2893: Failed to specialize
// function template 'void fmt::v11::detail::buffer<T>::append(const U *,const
// U *)'
#ifndef FMT_DETAIL_EXPLICIT_INSTANTIATIONS
#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1930
FMT_CONSTEXPR20
#endif
void
Expand Down
7 changes: 5 additions & 2 deletions include/fmt/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,11 @@ auto format_to_n(OutputIt out, size_t n, const S& fmt, Args&&... args)

template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
FMT_CONSTEXPR20 auto formatted_size(const S& fmt, const Args&... args)
-> size_t {
#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1930
FMT_CONSTEXPR20
#endif
auto
formatted_size(const S& fmt, const Args&... args) -> size_t {
auto buf = detail::counting_buffer<>();
fmt::format_to(appender(buf), fmt, args...);
return buf.count();
Expand Down
1 change: 0 additions & 1 deletion src/format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//
// For the license information refer to format.h.

#define FMT_DETAIL_EXPLICIT_INSTANTIATIONS 1
#include "fmt/format-inl.h"

FMT_BEGIN_NAMESPACE
Expand Down
2 changes: 1 addition & 1 deletion test/compile-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ TEST(compile_test, format_to_n) {
EXPECT_STREQ("2a", buffer);
}

# if FMT_USE_CONSTEVAL
# if FMT_USE_CONSTEVAL && (!FMT_MSC_VERSION || FMT_MSC_VERSION >= 1930)
TEST(compile_test, constexpr_formatted_size) {
FMT_CONSTEXPR20 size_t size = fmt::formatted_size(FMT_COMPILE("{}"), 42);
EXPECT_EQ(size, 2);
Expand Down

0 comments on commit 67eb7ed

Please sign in to comment.