Check whether a type is a instantiated by a template struct
Chris Cain
clcain at uncg.edu
Sat Aug 11 12:06:21 PDT 2012
On Saturday, 11 August 2012 at 18:56:30 UTC, Jakob Ovrum wrote:
> struct S(T) {}
>
> template isS(T : S!U, U) {
> enum isS = true;
> }
>
> template isS(T) {
> enum isS = false;
> }
>
> static assert(isS!(S!float));
> static assert(!isS!float);
Same idea, but doing it with just one template and using static
ifs...
struct S(T) {}
template isS(T) {
static if(is(T _ : S!U, U))
enum isS = true;
else
enum isS = false;
}
static assert(isS!(S!float));
static assert(!isS!float);
More information about the Digitalmars-d-learn
mailing list