On Tuesday, 13 September 2022 at 08:43:45 UTC, Nick Treleaven
wrote:
On Tuesday, 13 September 2022 at 03:00:17 UTC, Kyle Ingraham
wrote:
Any suggestions for being able to call one function for any
instance given but maintain flexible return types?
Not sure if it helps, but you can define final methods in an
interface, which can call virtual interface methods:
```d
interface PathConverter
{
string getValue();
final T toD(T)()
{
import std.conv : to;
return to!T(getValue());
}
}
```
Not tested as AFK.
Thanks for the suggestion Nick. I solved this by storing structs
as `void*` in a wrapper struct with information about their
module and identifier saved elsewhere. I use that information to
setup casts to the appropriate type then call `toD`. That way I
can call the same method for functions that return different
types and store disparate structs to the same wrapper struct. The
wrapper struct gets used in function signatures.