|
Boost : |
Subject: [boost] [type_traits] A partial implementation of boost::is_constructible
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2016-02-19 02:46:50
I filed a ticket about a potential improvement of type trait
boost::is_constructible: https://svn.boost.org/trac/boost/ticket/12003
I am solving the following problem. I have a one-argument perfect
forwarding explicit constructor and want to constrain it only to the cases
when T is constructible from U:
```
template <typename T>
struct optional
{
template <typename U>
explicit optional(U&& v, ENABLE_IF(is_constructible<T, U&&>))
{...}
};
```
I cannot afford to use the "fallback" implementation of
boost::is_constructible (the one that forwards to is_convertible) because I
would be constraint my constructor too much: I would rather leave it
under-constrained.
I do not need the full implementation of is_constructible (that would need
variadic templates) because I am only using the two-argument version (and I
suppose my problem is not isolated).
I would like a partial implementation of is_constructible that works
correctly for two arguments only; and a macro that allows me to test if it
is available.
I suspect that this is the common case that you use only the two-argument
version, and implementing only this would handle a quite a big number of
all the use cases. Is it something that fits into the library scope, or do
is it something I would have to implement myself?
Regards,
&rzej
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk