Difference between "can call" and "can compile"

Steven Schveighoffer schveiguy at gmail.com
Tue Sep 15 19:12:04 UTC 2020

On 9/15/20 10:18 AM, WebFreak001 wrote:
> On Monday, 7 September 2020 at 14:57:24 UTC, Steven Schveighoffer wrote:
>> Consider a template function like this:
>> void foo(T)(T v)
>> {
>>    auto x = v.someProperty;
>> }
>> [...]
> This is already possible from a library solution, see 
> https://forum.dlang.org/post/iribazqozceygujkvvjg@forum.dlang.org
> However I imagine it is slow because of mixin operations + not well 
> defined because it uses stringof, but if you just want it in some small 
> project of yours you can just use that.

But that's the issue. If I know what small set of types should work, 
then I can just write overloads for those types.

It's when I don't know what type is going to be passed in.

I could probably switch to using "hasMember" in this use case, which is 
likely to be correct for all purposes that I have. It's just not 
applicable to a public library, which might use things other than members.


More information about the Digitalmars-d mailing list