On Wednesday, October 18, 2017 10:36:41 Per Nordlöw via Digitalmars-d-learn wrote: > On Wednesday, 18 October 2017 at 10:17:38 UTC, Biotronic wrote: > > Make them templates, that should solve the problem: > > > > struct S(T) { > > > > void foo()() { > > > > compileerror; > > > > } > > > > } > > Yeah I've thought of that. > > I still would like to have it built-in to the compiler.
If you actually needed all of the member functions to fully exist, that would make life a lot harder (e.g. if you're doing something with language bindings and need to guarantee that a particular template instantiation fully exists). And if you suddenly couldn't guarantee that everything within a template was instantiated when the template was instantiated, then you basically have code that looks like it exists but doesn't actually, and that would make it rather difficult to know what code actually exists, whereas right now, if you instantiate a template, you know exactly what code then exists because of that instantiation. At least with the ability to separately templatize member functions, you can control what's going on. - Jonathan M Davis