On 02/07/2017 01:17 AM, Chris Katko wrote:

void function3(T)(T) //hypothetical, specify the datatype in the
argument list
    {
    T data;
    }

Related:

  https://dlang.org/library/object/type_info.html

and

  https://dlang.org/library/object/object.factory.html

This compiles but I'm not sure how to use it effectively:

import std.stdio;

auto function3(TypeInfo ti)
{
    return ti.initializer();
}

void main()
{
    writeln(function3(typeid(float)));
    writeln(function3(typeid(double)));
}

Ali

Reply via email to