
AMDG Joachim Faulhaber wrote:
<snip>
template<class Domain, class Codomain, ...> class interval_map{ //(3) Adaptable functor template<template<class>class Combinator> interval_map& add(const value_type& value_pair, const Combinator<Codomain>& combine) { /*combine functor passed or called somewhere*/ }
Can't you use: template<class Combinator> interval_map& add(const value_type& value_pair, const Combinator& combine); ? In other words, does Combinator really have to be a template?
Now, there seems to be a convention from the STL that functors shall be passed BY VALUE.
<snip>
I do not really understand this convention and feel some resistance to follow it. In addition the call by value implementation can (and will) lead to heavy inefficiency by unaware usage of fat functors.
The assumption is that function objects are not fat. If you have a large function object, it is always possible to create another function object that just stores a reference to the original function object.
So I browsed through some boost libraries and found that functors are passed by reference there (e.g. accumulators, fusion).
Final question: What is the boost standard on passing functors, that I can adapt to?
You can go either way. There is no official Boost policy about this. In Christ, Steven Watanabe