Skip to content

Compilation failure when converting decimal to string with {fmt} and FMT_COMPILE #1537

Closed

Description

@GeoffreyAA

After the commits of PR #1536, the following fails to compile on VS2026 18.11.2:

void DecimalToString(decimal64_t x, wchar_t *s, size_t size)
{
	if (s != nullptr && size > 0)
	{
		auto r = fmt::format_to_n(s, size - 1, FMT_COMPILE(L"{}"), x);
		*r.out = L'\0';
	}
}

Error C2679 binary '=': no operator found which takes a right-hand operand of type 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' (or there is no acceptable conversion) D:\x\Include\boost\decimal\detail\format_render.hpp 246

Removing FMT_COMPILE works. So does std::format_to_n().

Nonetheless, the following compiles:

std::wstring DecimalToString(decimal64_t x)
{
	return fmt::format(FMT_COMPILE(L"{}"), x);
}

Would this be an issue in Boost.Decimal or {fmt}?

Many thanks for your excellent library!

Activity

  1. mborland commented on Oct 28, 2026

    @mborland
    Member

    Good question. Let me take a look today and get back to you.

  2. GeoffreyAA commented on Oct 28, 2026

    @GeoffreyAA
    Author

    Thank you.

  3. GeoffreyAA commented on Oct 29, 2026

    @GeoffreyAA
    Author

    @mborland,

    Working like a charm. Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions