
At Thu, 31 Mar 2011 19:20:47 -0700, Mostafa wrote:
On Thu, 31 Mar 2011 07:02:43 -0700, Dave Abrahams <dave@boostpro.com> wrote:
At Thu, 31 Mar 2011 08:53:02 -0500, Andrew Sutton wrote:
I will say that our design does take a slightly more object-oriented approach (g.size(), for example), but that hardly precludes adaptation. Adaptors would have to be written as classes, but that shouldn't be a big deal.
I think you underestimate the cost of adaptation-via-wrapper and urge you to stick with free functions unless you have a really good reason to do otherwise.
Can you elaborate?
Briefly: if you have to wrap things to get them to conform to a concept, then they are no longer the original thing anymore. For example: T x, y; Wrapper w(y); swap(x,w); // <=== compilation fails A bigger issue is the question of whether the wrapper has value semantics or not: do you pay to copy y into w, or do you merely refer to y from w? The former can be costly, but the latter can be wrong. I believe other cases of this general problem will crop up repeatedly in real code. -- Dave Abrahams BoostPro Computing http://www.boostpro.com