Compiler complaining about code that can't be reached, builtin types .equals()
Sean Grimes via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 25 12:01:19 PDT 2015
On Thursday, 25 June 2015 at 18:43:31 UTC, Ali Çehreli wrote:
> On 06/25/2015 11:26 AM, Sean Grimes wrote:
>
> Here is a short example which treats 'int' and 'double' as
> built-in only:
>
> import std.typetuple;
>
> bool isBuiltIn(T)()
> {
> foreach (T2; TypeTuple!(int, double/*, ... */)) {
> if (is (T2 == T)) {
> return true;
> }
> }
>
> return false;
> }
>
> struct S(V)
> {
> void foo(V v)
> {
> static if (!isBuiltIn!V) {
> /* Assumes that non-built-ins support bar(). */
> v.bar();
> }
> }
> }
>
> void main()
> {
> auto s = S!int();
> s.foo(42);
> }
>
> Ali
Ali,
Thanks that works for me.
- Sean
More information about the Digitalmars-d-learn
mailing list