Re: Static if a Function Exists

2020-04-04 Thread Jonathan Levi via Digitalmars-d-learn
On Friday, 3 April 2020 at 07:08:03 UTC, WebFreak001 wrote: maybe not the optimal solution because stringof isn't properly defined, but currently I don't think there is a better way than: template matchesTemplateConstraints(alias fn, Args...) { enum def = fn.stringof; // private void te

Re: Static if a Function Exists

2020-04-03 Thread WebFreak001 via Digitalmars-d-learn
On Friday, 3 April 2020 at 01:03:01 UTC, Jonathan Levi wrote: I am trying to make a templated function for any arguments which will work for another. Like this: ``` class Cls { auto opBinary(string op, T)(T b) if (__traits(compiles, opBinaryImpl!op(this, b))) { return opBina

Static if a Function Exists

2020-04-02 Thread Jonathan Levi via Digitalmars-d-learn
I am trying to make a templated function for any arguments which will work for another. Like this: ``` class Cls { auto opBinary(string op, T)(T b) if (__traits(compiles, opBinaryImpl!op(this, b))) { return opBinaryImpl!op(this, b); } } auto opBinaryImpl(string op, T)(Cl