Home Dashboard Directory Help
Search

std::is_*constructible<T>::value == true for abstract classes. by Cassio Neri


Status: 

Closed


2
0
Sign in
to vote
Type: Bug
ID: 808132
Opened: 11/8/2013 4:13:40 PM
Access Restriction: Public
1
Workaround(s)
view
1
User(s) can reproduce this bug

Description

If T is an abstract class then

std::is_constructible<T>::value == true
std::is_default_constructible<T>::value == true
std::is_copy_constructible<T>::value == true
std::is_move_constructible<T>::value == true

whereas all of the above should give std::*constructible<T>::value == false (which is the case with gcc 4.8.1, clang 3.3 and icc 13.1.3).

The culprit is the compiler hook '__is_constructible' which disconsider whether the class is abstract or not.

It's possible (I haven't test) that std::is_trivially_*constructible also gives wrong results.
Details
Sign in to post a comment.
Posted by Microsoft on 11/21/2013 at 10:56 AM
Hi Cassio:
    Thanks for reporting the issue.
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next major release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by Microsoft on 11/10/2013 at 6:45 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 11/8/2013 at 4:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Cassio Neri on 11/8/2013 at 4:22 PM
Define your own traits (as shown below) and use them instead of their corresponding ones in namespace std.
Notice that typename U = ... is required as a workaround for another bug:
https://connect.microsoft.com/VisualStudio/feedback/details/808130/alias-template-issue-involving-non-type-template-parameter-and-two-levels-of-template-aliasing#tabs

----

template <typename T, typename... Args>
using is_constructible = std::integral_constant<bool,
    std::is_constructible<T, Args...>::value && !std::is_abstract<T>::value>;

template <typename T, typename U = is_constructible<T>>
using is_default_constructible = U;

template <typename T, typename U = is_constructible<T, const T&>>
using is_copy_constructible = U;

template <typename T, typename U = is_constructible<T, T&&>>
using is_move_constructible = U;