Testing for template argument being result of takeExactly
Timon Gehr
timon.gehr at gmx.ch
Mon Sep 24 15:14:42 PDT 2012
On 09/24/2012 09:41 AM, monarch_dodra wrote:
> ...
>
> Regarding the ".init" issue, I hadn't thought of that, but it can
> be worked around pretty easily with an is(R r):
>
> --------
> template Hello(R)
> if ( is(R r) &&
> is(typeof(takeExactly(r, 1))) &&
> is(R == typeof(takeExactly(r, 1)))
> )
> {
> alias R Hello;
> }
> --------
> After that, I guess it is indeed one implementation detail vs the
> other.
>
I don't think this does what you think it does. The 'is(R r)' declares r
to be an alias for R. So 'r' is a type in that code snippet.
Also, is(typeof(takeExactly(R, 1))) && is(R == typeof(takeExactly(R, 1)))
can be written in a more compact way as
is(typeof(takeExactly(R, 1)) == R)
> IMO, it really depends on whether or not you'd want "int[]" to be
> considered the return type of a takeExactly :/ Maybe it is, maybe
> it ain't.
More information about the Digitalmars-d-learn
mailing list