[cfe-dev] What does __is_constructible actually check?
Marshall Clow
mclow.lists at gmail.com
Tue Mar 18 07:58:38 PDT 2014
Consider this code:
#include <iostream>
#include <cassert>
struct Abstract {
Abstract () {}
~Abstract () {}
virtual bool operator() () const = 0;
};
struct Private {
private:
Private () {}
~Private () {}
};
int
main()
{
std::cout << __is_constructible(int) << std::endl;
std::cout << __is_constructible(Abstract) << std::endl;
std::cout << __is_constructible(Private) << std::endl;
}
What would you expect this to print?
I would expect:
1
0
0
but instead, it prints.
Has __is_constructible
1
1
0
In other words, __is_constructible(Abstract) returns true.
But I can’t actually _construct_ an instance of Abstract:
junk2.cpp:27:11: error: variable type 'Abstract' is an abstract class
Abstract a;
^
junk2.cpp:7:15: note: unimplemented pure virtual method 'operator()' in
'Abstract'
virtual bool operator() () const = 0;
^
1 error generated.
Is this behavior deliberate? Or just a bug?
— Marshall
More information about the cfe-dev
mailing list