[Issue 11326] move functions are not properly constrained and work improperly with templated functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Oct 22 11:42:40 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11326



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-10-22 11:42:39 PDT ---
Ok as it turns out checking for template member functions is actually very
difficult. I don't think we have the proper traits to derive whether something
is a templated member function that can be called a certain way belonging to an
aggregate and **not** a UFCS function.

The problem is really this:

static if (is(typeof(r.moveFront)))

This will end up calling a UFCS function if there's no member function, that's
why the current implementation uses an address-of operator. We need to get rid
of these styles of tricks and implement proper introspection utilities, meaning
we have helper templates in Phobos or __traits() which can tell us:

- Does symbol "abc" exist for an aggregate
  -> We already have hasMember!()

- Is the symbol a function which can be called via "obj.abc()"
  -> Not easy to figure out. Just testing "obj.abc()" may end up calling a UFCS
function instead. And a simple "&obj.abc" doesn't work for templated functions
either (current situation).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list