On Friday, 1 January 2016 at 16:13:47 UTC, Adam D. Ruppe wrote:
On Friday, 1 January 2016 at 15:55:53 UTC, Bottled Gin wrote:
That gives me a false positive if a defined constructor has
The helper loops through all the overloads looking for one that
is assignable to a zero-arg pointer - meaning it matches the
default signature, ignoring default params.
Then it just returns if it found one.
Why not just checking that a ctor has no parameter ?
~~~~~~
template HasDefaultConstructor(Class)
{
bool helper()
{
bool result;
foreach(overload; __traits(getOverloads, Class, "__ctor"))
{
auto fun = &overload;
import std.traits: Parameters;
static if((Parameters!fun).length == 0)
result = true;
}
return result;
}
enum HasDefaultConstructor = helper();
}
~~~~~~