Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2000-11-03 16:11:27


I've read the documents, and looked over the any.hpp file. I think "any"
should be accepted into boost. I have not made my own test suite. Sorry I'm
short of time this week.

Suggestions:
============
any.hpp should add the following bit of code.

namespace std {
void swap(boost::any & lhs, boost::any & rhs) { lhs.swap(rhs); }
}

Reasoning: If you are going to provide an optimized swap you should let the
namespace std know about it.

I think this is a legal overload. (Feel free to cite chapter and verse for
why not.)

---------------
As an addition I'd also prefer that "any" take a template parameter
allocator instead of calling the global new. (That would make any a
template, which would make the above swap addition illegal.)

Reasoning, it would make it more flexible for user controlled memory.

Alternatively would it be possible for holder to have an operator new, which
called the ValueType::operator new() ? That would allow it to call the user
type new. (Caveat I haven't tried this so I'm not even sure that its
possible.)

---------------
Question: Does it make sense to add the operator!() to any? (Or does the
conversion to void * happen first and then operator!()? )

as in
  any a;
  if (!a) {...}

---------------
I tried to search the history for "any" and comparisons, and thanks to the
frequent use of the word "any" it was more work that it was worth. So I hope
not to start a chain of "We discussed this in April and rejected it because"
discussions, was there any discussion of whether any should provide the
operator==() and operator>() ? I was thinking about forwarding the
comparisons to the native types and letting it either compile or not.
(Depending on whether the types had the necessary operations.)

  Yours,
 -gary-

gary.powell_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk