Why does std :: is_constructible stop in immediate context?

Comes from this thread. Also relevant to this topic.

My question is: why does it std::is_constructiblestop in the immediate context? I think users std::is_constructiblewould expect it to work at full depth and give an accurate answer. With this immediate context, you can only std::is_constructiblegive you the green light, only to get a tough compiler error when you actually do it. Doesn't that defeat the original goal and goal std::is_constructible. Now it looks useless to me. I think it std::looks_constructible_at_first_sightwill be the best name for the current semantics :(

+4
source share
1 answer

If your constructor signature is much more solvable than it should be, then the problem is not is_constructible. In the original example

template <typename... Ts, typename=decltype(base{std::declval<Ts>()...})>
aggregate_wrapper(Ts&&... xs)
    : base{std::forward<Ts>(xs)...} {/*…*/}

performs this work. If is_constructible"false" gives a green light, so your constructor template may be mistakenly selected over other constructors because the overload resolution finds the best match.

/. , . is_constructible , , , SFINAE, - , , .
, , , is_constructible . , is_constructible .

+1

Source: https://habr.com/ru/post/1625930/


All Articles