Hacker News new | past | comments | ask | show | jobs | submit login

Exactly what I came here to say.

The error messages produced by g++ for anything template related are a really difficult hurdle to overcome as a beginner. I am sure once you mastered it, it does make sense -- but right now it's a source of frustration for me.




I haven't used GCC in a while, but clang's template error msgs are way better than MSVC's in my experience. Still not like--good--haha. Like not Elm-level.


concepts will fix that.

For the time being, any library writer can improve their own error messages using a mix of constexpr if, static_assert and enable_if.


Yeah I'm looking forward to seeing how concepts work out in practice.

Also, to clarify on the original point, in this case it doesn't require that much template trickery. Most attributes could be handled as `.foo(Foos::BAR_1)` to set HTML attribute `foo="bar_1"` for example and have things still be 'type safe' on the C++ side. I just pass strings through right now to have a catch-all API, then I could go back on it after some real use and see what styles come in practice.

The only template it happens to use right now is the usual `template<typename F>` with `F &&f` to let you pass an inlineable lambda. I could use `static_assert` as you say, with `std::is_invocable_v`, and offer a nicer error message when that doesn't match.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: