Skip to content

Error messages are unreadable #28

Open
@Morwenn

Description

@Morwenn

In its current state, the library produces rather unreadable error messages and can spawn several hundreds of lines of cryptic error messages for a simple missing const without a single hint to what may be wrong. Honestly, this is a major drawback and the crazy amount of SFINAE insanity doesn't help.

We can't realistically put static assertions all over the place because many mechanisms in the library rely on SFINAE. There may be other ways to handle errors.


Some elements of answer:

  • Use strong typedefs via inheritance instead of templates aliases to define sorters.
  • Concepts will probably help to reduce the error madness, but we have to wait for C++20 at least.
  • If the DR allowing to write using Sorters::operator()...; makes its way to C++17, it might remove some annoying errors dues to recursion.
  • Static assertions could be used after in the sorters' operator() to ensure that the iterator category of the parameter is correct. By the time the operator is called, all of the SFINAE checks should already have passed and the only remaining thing before the actual sort is an eventual tag dispatch. Unfortunately, I doubt that it is possible to automate this mechanism.
  • Give a default template parameter to hybrid_adapter which would act as a fallback if none of the sorters are picked and trigger an explicit error. Getting the mechanism to work with nested hybrid_adapter seems crazy hard though.
  • Update the tutorials to stress out the importance of errors to potential sorter writers.
  • More static assertions for sorters that only accept copyable types. The error messages when trying to feed a collection of move-only types to a sorter that needs to copy them are not really readable (solved by Make all sorts work with move-only types #15, all sorters now work with move-only types).
  • Moving the SFINAE condition of type-specific sorters to a dedicated trait may allow to add more static_assert to the sorter in the simplest case in order to reduce the amount of SFINAE logs (see Refactoring of the SFINAE conditions of the sorters #113).

To be honest the errors occuring when a const is missing are the worst kind. There might be ways to require less const everywhere while still providing it when needed.


A few resources about getting better error messages:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions