Opened 7 years ago

Closed 5 years ago

#12003 closed Bugs (fixed)

Implement is_constrructible<T, U> -- no variadics

Reported by: akrzemi1 Owned by: John Maddock
Milestone: To Be Determined Component: type_traits
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc: akrzemi1@…, raad@…, marci_r@…

Description

In the current implementation of trait boost::is_constructible, unless the compiler offers variadic templates (and some more), is implemented as boost::is_convertible, and that's it.

I understand the limitations, but would it be possible to provide a more accurate version for the case with exactly two parameters: boost::is_constructible<T, U>. This would check the construction with a single argument, so it does not require variadic templates, and it would cover a significant number of use cases. For instance it would unblock my ticket:

https://svn.boost.org/trac/boost/ticket/12002

Change History (6)

comment:1 by raad@…, 7 years ago

Cc: raad@… added

comment:2 by akrzemi1, 7 years ago

And possibly define a macro saying if at least two-argument version is implemented, in a form similar to Boost.Config. This way the user could make a decision whether to use the trait or not.

comment:3 by marci_r@…, 7 years ago

Cc: marci_r@… added

comment:4 by John Maddock, 7 years ago

Which compiler are we talking about here? We really do need a C++11 compiler to implement even a non-variadic version. We could possibly extend it to msvc-12 and gcc-4.4 in a non-variadic form (or possibly there would still be compiler bugs preventing that - I seem to remember the issue with gcc-4.4 was with use of decltype). If you're hoping for a C++03 version then you'll need to supply a PR.

comment:5 by akrzemi1, 7 years ago

Visual Studio for, I think, two releases supported decltype but no variadic templates. I really had this compiler in mind.

Whether this makes sense or not is one question, but the other question remains. It is not strictly in the scope of this library, but could you give me a macro that says if the is_constructible works correctly or falls back to a negative default? Currently I had to repeat the long #if from is_constructible.hpp, as I cannot rely on the 'safe' default.

comment:6 by John Maddock, 5 years ago

Resolution: fixed
Status: newclosed

Somewhat better late than never, the macro BOOST_TT_IS_CONSTRUCTIBLE_CONFORMING will now be set when the trait is fully usable.

Note: See TracTickets for help on using tickets.