Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Literal-based API: error: ‘struct fmt::v5::formatter<UUID, char, void>’ has no member named ‘parse’ #1088

Closed
chronoxor opened this issue Mar 18, 2019 · 2 comments

Comments

@chronoxor
Copy link
Contributor

chronoxor commented Mar 18, 2019

"{}"_format(UUID()) failed to compile under GCC 8.2.0 (Ubuntu 18.04.2 x64) for user classe with ostream friend operator (VS 2017 is ok):

// Compiles fine!
fmt::format("{}", UUID());
// error: ‘struct fmt::v5::formatter<CppCommon::UUID, char, void>’ has no member named ‘parse’
"{}"_format(UUID());
fmt/format.h:2140:12: error: ‘struct fmt::v5::formatter<UUID, char, void>’ has no member named ‘parse’
   return f.parse(ctx);
          ~~^~~~~

where UUID is my custom class with ostream operator:

class UUID
{
public:
    UUID() : _data() { _data.fill(0); }
    explicit UUID(const std::string& uuid);
    explicit UUID(const std::array<uint8_t, 16>& data) : _data(data) {}
    UUID(const UUID&) = default;
    UUID(UUID&&) noexcept = default;
    ~UUID() = default;

    UUID& operator=(const std::string& uuid)
    { _data = UUID(uuid).data(); return *this; }
    UUID& operator=(const std::array<uint8_t, 16>& data)
    { _data = data; return *this; }
    UUID& operator=(const UUID&) = default;
    UUID& operator=(UUID&&) noexcept = default;

    //! Get string from the current UUID in format "00000000-0000-0000-0000-000000000000"
    std::string string() const;

    //! Output instance into the given output stream
    friend std::ostream& operator<<(std::ostream& os, const UUID& uuid)
    { os << uuid.string(); return os; }

private:
    std::array<uint8_t, 16> _data;
};
@chronoxor chronoxor changed the title error: ‘struct fmt::v5::formatter<CppCommon::UUID, char, void>’ has no member named ‘parse’ error: ‘struct fmt::v5::formatter<UUID, char, void>’ has no member named ‘parse’ Mar 19, 2019
@chronoxor chronoxor changed the title error: ‘struct fmt::v5::formatter<UUID, char, void>’ has no member named ‘parse’ Literal-based API: error: ‘struct fmt::v5::formatter<UUID, char, void>’ has no member named ‘parse’ Mar 19, 2019
@vitaut
Copy link
Contributor

vitaut commented Mar 19, 2019

Thanks for reporting. This is an unfortunate side effect of the fix to #952. Need to plug in the fallback formatter that implements operator<< support into the compile-time check machinery.

@vitaut
Copy link
Contributor

vitaut commented Mar 22, 2019

Should be fixed in da0ea41.

@vitaut vitaut closed this as completed Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants