'standard' free functions for operators, etc

In many parts of boost, free functions are used as customization points for
various things, better explained with examples:
intrusive_ptr_add_ref()
advance/increment/etc in boost iterator library
etc
Are there other examples?
Now consider my example:
template

Gottlob Frege wrote: [...]
typedef int RecordID;
assign(RecordID id, SomeValue const & value) { // do the assignment }
But of course, RecordID is just a typedef, not a 'strong typedef', so it could be just one example of many assign(int, SomeValue), completely unrelated to each other.
So how should that be handled? Specific naming (using 'myclass_') lowers the chances of a problem, but doesn't remove it. Which means that, in theory at least, intrusive_ptr has the same problem:
intrusive_ptr_add_ref(some_typedef_that_is_really_an_int) { ... }
intrusive_ptr_add_ref(some_OTHER_typedef_that_is_also_an_int) { ... }
intrusive_ptr_add_ref is passed a pointer to a class with an embedded reference count. It doesn't matter how many typedefs resolve to X*, X still has its reference count that needs to be incremented. You only run into the problem when "assign" is underspecified and overloaded to mean different things in different contexts.
participants (2)
-
Gottlob Frege
-
Peter Dimov