Cannot use the same template arguments on function as the ones on struct
MrSmith via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 11 14:14:43 PST 2015
Here I have templated struct that matches type with CborConfig
tempate specialization
CborConfig will have more parameters in future and all of them
will be accessed via alias members, so I've used variadic (T...)
parameter whule matching.
-------
template CborConfig(_nonSerializedAttribute)
{
struct CborConfig
{
alias nonSerializedAttribute = _nonSerializedAttribute;
}
}
/// Default non-serialized attribute type
struct NonSerialized{}
/// This CborConfig instantiation will be used by default.
alias defaultCborConfig = CborConfig!(NonSerialized,
NonSerialized);
struct AccepterT(Config : CborConfig!(T) = defaultCborConfig,
T...)
{
pragma(msg, T);
}
// template f379.accepter cannot deduce function from argument
types !()()
void accepter(Config : CborConfig!(T) = defaultCborConfig, T...)()
{
pragma(msg, T);
}
-------
^^^^^^^
http://dpaste.dzfl.pl/5f1d5d5d9e19
Instead I need to use template constraint which is less compact.
http://dpaste.dzfl.pl/571ae84d783e
Why such behavior happens?
More information about the Digitalmars-d-learn
mailing list