fmt – Formatting of non-void pointers is disallowed

This code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#pragma once
#include <fmt/format.h>
template <typename EnumType>
requires std::is_enum_v<EnumType>
struct fmt::formatter<EnumType> : fmt::formatter<std::underlying_type_t<EnumType>>
{
// Forwards the formatting by casting the enum to its underlying type
auto format(const EnumType& enumValue, fmt::format_context& ctx) const
{
return fmt::formatter<std::underlying_type_t<EnumType>>::format(
static_cast<std::underlying_type_t<EnumType>>(enumValue), ctx);
}
};
template<typename Format, typename... Args>
inline std::string StringFormat(Format&& fmt, Args&&... args)
{
try
{
if constexpr (std::is_same_v<std::decay_t<Format>, char*> || std::is_same_v<std::decay_t<Format>, const char*>)
{
// When format string is not known at compile-time
return fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...);
}
else
{
// When format string is known at compile-time
return fmt::format(std::forward<Format>(fmt), std::forward<Args>(args)...);
}
}
catch (const fmt::format_error& formatError)
{
std::string error = "An error occurred formatting string "" + std::string(fmt) + "" : " + std::string(formatError.what());
return error;
}
}
/// Returns true if the given char pointer is null.
inline bool IsFormatEmptyOrNull(char const* fmt)
{
return fmt == nullptr;
}
/// Returns true if the given std::string is empty.
inline bool IsFormatEmptyOrNull(std::string const& fmt)
{
return fmt.empty();
}
</code>
<code>#pragma once #include <fmt/format.h> template <typename EnumType> requires std::is_enum_v<EnumType> struct fmt::formatter<EnumType> : fmt::formatter<std::underlying_type_t<EnumType>> { // Forwards the formatting by casting the enum to its underlying type auto format(const EnumType& enumValue, fmt::format_context& ctx) const { return fmt::formatter<std::underlying_type_t<EnumType>>::format( static_cast<std::underlying_type_t<EnumType>>(enumValue), ctx); } }; template<typename Format, typename... Args> inline std::string StringFormat(Format&& fmt, Args&&... args) { try { if constexpr (std::is_same_v<std::decay_t<Format>, char*> || std::is_same_v<std::decay_t<Format>, const char*>) { // When format string is not known at compile-time return fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...); } else { // When format string is known at compile-time return fmt::format(std::forward<Format>(fmt), std::forward<Args>(args)...); } } catch (const fmt::format_error& formatError) { std::string error = "An error occurred formatting string "" + std::string(fmt) + "" : " + std::string(formatError.what()); return error; } } /// Returns true if the given char pointer is null. inline bool IsFormatEmptyOrNull(char const* fmt) { return fmt == nullptr; } /// Returns true if the given std::string is empty. inline bool IsFormatEmptyOrNull(std::string const& fmt) { return fmt.empty(); } </code>
#pragma once

#include <fmt/format.h>

template <typename EnumType>
requires std::is_enum_v<EnumType>
struct fmt::formatter<EnumType> : fmt::formatter<std::underlying_type_t<EnumType>>
{
    // Forwards the formatting by casting the enum to its underlying type
    auto format(const EnumType& enumValue, fmt::format_context& ctx) const
    {
        return fmt::formatter<std::underlying_type_t<EnumType>>::format(
                static_cast<std::underlying_type_t<EnumType>>(enumValue), ctx);
    }
};

template<typename Format, typename... Args>
inline std::string StringFormat(Format&& fmt, Args&&... args)
{
    try
    {
        if constexpr (std::is_same_v<std::decay_t<Format>, char*> || std::is_same_v<std::decay_t<Format>, const char*>)
        {
            // When format string is not known at compile-time
            return fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...);
        }
        else
        {
            // When format string is known at compile-time
            return fmt::format(std::forward<Format>(fmt), std::forward<Args>(args)...);
        }
    }
    catch (const fmt::format_error& formatError)
    {
        std::string error = "An error occurred formatting string "" + std::string(fmt) + "" : " + std::string(formatError.what());
        return error;
    }
}

/// Returns true if the given char pointer is null.
inline bool IsFormatEmptyOrNull(char const* fmt)
{
    return fmt == nullptr;
}

/// Returns true if the given std::string is empty.
inline bool IsFormatEmptyOrNull(std::string const& fmt)
{
    return fmt.empty();
}

Gives me the following error:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>In file included from V:/Vibranium-Core/dep/Vibranium-Engine/Utils/StringFormat.h:7:
In file included from V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/format.h:56:
V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/base.h:1621:17: error: static assertion failed due to requirement 'formattable_pointer': Formatting of non-void pointers is disallowed.
1621 | static_assert(formattable_pointer,
| ^~~~~~~~~~~~~~~~~~~
V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/base.h:2004:20: note: in instantiation of function template specialization 'fmt::detail::make_arg<true, fmt::context, const wchar_t *, 0>' requested here
2004 | return {{detail::make_arg<NUM_ARGS <= detail::max_packed_args, Context>(
| ^
V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/format.h:4354:28: note: in instantiation of function template specialization 'fmt::make_format_args<fmt::context, const wchar_t *, 1ULL, 0ULL, 15ULL, 0>' requested here
4354 | return vformat(fmt, fmt::make_format_args(args...));
| ^
V:/Vibranium-Core/dep/Vibranium-Engine/Utils/StringFormat.h:29:25: note: in instantiation of function template specialization 'fmt::format<const wchar_t *>' requested here
29 | return fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...);
| ^
V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:70:35: note: in instantiation of function template specialization 'StringFormat<const char (&)[37], const wchar_t *>' requested here
70 | outMessage(filter, level, StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
| ^
V:Vibranium-CoreSourceAuthServerMain.cpp:67:9: note: in instantiation of function template specialization 'Log::outMessage<const char (&)[37], const wchar_t *>' requested here
67 | LOG_ERROR("[AS] Error in configuration file: {}", config_file.c_str());
| ^
V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:197:5: note: expanded from macro 'LOG_ERROR'
197 | LOG_MESSAGE_BODY("", LOG_LEVEL_ERROR, __VA_ARGS__)
| ^
V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:160:18: note: expanded from macro 'LOG_MESSAGE_BODY'
160 | LOG_EXCEPTION_FREE(filterType__, level__, __VA_ARGS__);
| ^
V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:136:19: note: expanded from macro 'LOG_EXCEPTION_FREE'
136 | sLog->outMessage(filterType__, level__, __VA_ARGS__);
| ^
6 warnings and 1 error generated.
mingw32-make[3]: *** [SourceAuthServerCMakeFilesAuthServer.dirbuild.make:136: Source/AuthServer/CMakeFiles/AuthServer.dir/Main.cpp.obj] Error 1
mingw32-make[3]: *** Waiting for unfinished jobs....
9 warnings generated.
6 warnings generated.
mingw32-make[2]: *** [CMakeFilesMakefile2:1955: Source/AuthServer/CMakeFiles/AuthServer.dir/all] Error 2
mingw32-make[1]: *** [CMakeFilesMakefile2:1962: Source/AuthServer/CMakeFiles/AuthServer.dir/rule] Error 2
mingw32-make: *** [Makefile:740: AuthServer] Error 2
</code>
<code>In file included from V:/Vibranium-Core/dep/Vibranium-Engine/Utils/StringFormat.h:7: In file included from V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/format.h:56: V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/base.h:1621:17: error: static assertion failed due to requirement 'formattable_pointer': Formatting of non-void pointers is disallowed. 1621 | static_assert(formattable_pointer, | ^~~~~~~~~~~~~~~~~~~ V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/base.h:2004:20: note: in instantiation of function template specialization 'fmt::detail::make_arg<true, fmt::context, const wchar_t *, 0>' requested here 2004 | return {{detail::make_arg<NUM_ARGS <= detail::max_packed_args, Context>( | ^ V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/format.h:4354:28: note: in instantiation of function template specialization 'fmt::make_format_args<fmt::context, const wchar_t *, 1ULL, 0ULL, 15ULL, 0>' requested here 4354 | return vformat(fmt, fmt::make_format_args(args...)); | ^ V:/Vibranium-Core/dep/Vibranium-Engine/Utils/StringFormat.h:29:25: note: in instantiation of function template specialization 'fmt::format<const wchar_t *>' requested here 29 | return fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...); | ^ V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:70:35: note: in instantiation of function template specialization 'StringFormat<const char (&)[37], const wchar_t *>' requested here 70 | outMessage(filter, level, StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...)); | ^ V:Vibranium-CoreSourceAuthServerMain.cpp:67:9: note: in instantiation of function template specialization 'Log::outMessage<const char (&)[37], const wchar_t *>' requested here 67 | LOG_ERROR("[AS] Error in configuration file: {}", config_file.c_str()); | ^ V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:197:5: note: expanded from macro 'LOG_ERROR' 197 | LOG_MESSAGE_BODY("", LOG_LEVEL_ERROR, __VA_ARGS__) | ^ V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:160:18: note: expanded from macro 'LOG_MESSAGE_BODY' 160 | LOG_EXCEPTION_FREE(filterType__, level__, __VA_ARGS__); | ^ V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:136:19: note: expanded from macro 'LOG_EXCEPTION_FREE' 136 | sLog->outMessage(filterType__, level__, __VA_ARGS__); | ^ 6 warnings and 1 error generated. mingw32-make[3]: *** [SourceAuthServerCMakeFilesAuthServer.dirbuild.make:136: Source/AuthServer/CMakeFiles/AuthServer.dir/Main.cpp.obj] Error 1 mingw32-make[3]: *** Waiting for unfinished jobs.... 9 warnings generated. 6 warnings generated. mingw32-make[2]: *** [CMakeFilesMakefile2:1955: Source/AuthServer/CMakeFiles/AuthServer.dir/all] Error 2 mingw32-make[1]: *** [CMakeFilesMakefile2:1962: Source/AuthServer/CMakeFiles/AuthServer.dir/rule] Error 2 mingw32-make: *** [Makefile:740: AuthServer] Error 2 </code>
In file included from V:/Vibranium-Core/dep/Vibranium-Engine/Utils/StringFormat.h:7:
In file included from V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/format.h:56:
V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/base.h:1621:17: error: static assertion failed due to requirement 'formattable_pointer': Formatting of non-void pointers is disallowed.
 1621 |   static_assert(formattable_pointer,
      |                 ^~~~~~~~~~~~~~~~~~~
V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/base.h:2004:20: note: in instantiation of function template specialization 'fmt::detail::make_arg<true, fmt::context, const wchar_t *, 0>' requested here
 2004 |   return {{detail::make_arg<NUM_ARGS <= detail::max_packed_args, Context>(
      |                    ^
V:/Vibranium-Core/dep/Vibranium-Engine/dep/fmt/include/fmt/format.h:4354:28: note: in instantiation of function template specialization 'fmt::make_format_args<fmt::context, const wchar_t *, 1ULL, 0ULL, 15ULL, 0>' requested here
 4354 |   return vformat(fmt, fmt::make_format_args(args...));
      |                            ^
V:/Vibranium-Core/dep/Vibranium-Engine/Utils/StringFormat.h:29:25: note: in instantiation of function template specialization 'fmt::format<const wchar_t *>' requested here
   29 |             return fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...);
      |                         ^
V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:70:35: note: in instantiation of function template specialization 'StringFormat<const char (&)[37], const wchar_t *>' requested here
   70 |         outMessage(filter, level, StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
      |                                   ^
V:Vibranium-CoreSourceAuthServerMain.cpp:67:9: note: in instantiation of function template specialization 'Log::outMessage<const char (&)[37], const wchar_t *>' requested here
   67 |         LOG_ERROR("[AS] Error in configuration file: {}", config_file.c_str());
      |         ^
V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:197:5: note: expanded from macro 'LOG_ERROR'
  197 |     LOG_MESSAGE_BODY("", LOG_LEVEL_ERROR, __VA_ARGS__)
      |     ^
V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:160:18: note: expanded from macro 'LOG_MESSAGE_BODY'
  160 |                         LOG_EXCEPTION_FREE(filterType__, level__, __VA_ARGS__); 
      |                         ^
V:/Vibranium-Core/dep/Vibranium-Engine/Logging/Log.h:136:19: note: expanded from macro 'LOG_EXCEPTION_FREE'
  136 |             sLog->outMessage(filterType__, level__, __VA_ARGS__); 
      |                   ^
6 warnings and 1 error generated.
mingw32-make[3]: *** [SourceAuthServerCMakeFilesAuthServer.dirbuild.make:136: Source/AuthServer/CMakeFiles/AuthServer.dir/Main.cpp.obj] Error 1
mingw32-make[3]: *** Waiting for unfinished jobs....
9 warnings generated.
6 warnings generated.
mingw32-make[2]: *** [CMakeFilesMakefile2:1955: Source/AuthServer/CMakeFiles/AuthServer.dir/all] Error 2
mingw32-make[1]: *** [CMakeFilesMakefile2:1962: Source/AuthServer/CMakeFiles/AuthServer.dir/rule] Error 2
mingw32-make: *** [Makefile:740: AuthServer] Error 2

why do I get this error and how can I fix it?

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật