https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93083

Martijn Otto <martijntje at martijnotto dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |martijntje at martijnotto dot 
nl

--- Comment #1 from Martijn Otto <martijntje at martijnotto dot nl> ---
The problem with deducing N is a stubborn one. I have run into the same issue
and tried to fix it by adding a constexpr size() method to explicitly provide
the size, but it doesn't seem to help and fails with the same error message
about being unable to deduce N:

template<unsigned N>
struct FixedString
{
    char buf[N + 1]{};
    constexpr FixedString(char const* s) {
        for (unsigned i = 0; i != N; ++i) buf[i] = s[i];
    }

    auto operator<=>(const FixedString&) const = default;
    constexpr operator char const*() const { return buf; }
    constexpr static unsigned size() noexcept { return N; }
};

template<unsigned N> FixedString(char const (&)[N]) -> FixedString<N - 1>;

template <FixedString... names>
struct name_list
{
    template <FixedString name>
    using add_name = name_list<
        names...,
        FixedString<name.size()>{ name }
    >;
};


int main()
{
    using names =
        name_list<>
        ::add_name<"Zaphod Beeblebrox">;

}

Reply via email to