-
Notifications
You must be signed in to change notification settings - Fork 275
Closed
Description
Just from a user perspective, the compiler errors were pretty arcane when I did not provide the right parameters to htile. htile implicitly requires all E&& elements to be derived from class element.
This is the general definition for these functions:
template <typename... E>
inline auto htile(E&&... elements)
{
using composite = array_composite<sizeof...(elements), htile_element>;
using container = typename composite::container_type;
composite r{};
r = container{{ share(std::forward<E>(elements))... }};
return r;
}It would be possible to add either
- an extra template parameter
std::enable_if_t<std::conjunction_v<std::is_convertible<E&, element&>...>, int> = 0- a C++20 concept:
requires std::conjunction_v<std::is_convertible<E&, element&>...>- or a static_assert:
static_assert(std::conjunction_v<std::is_convertible<E&, element&>...>, "All arguments must be convertible to 'element'");- and 2) takes the function out of the overload resolution, so it trips the syntax error highlighting in IDEs right away, which is pretty helpful. 3) at least gives a more useful message on what to fix.
So I'm just throwing this idea in that it may be useful to enforce these conditions more explicitly in the interfaces.
djowel and tiagobonetti
Metadata
Metadata
Assignees
Labels
No labels