Boost logo

Boost :

From: Sean Parent (sparent_at_[hidden])
Date: 2001-10-25 21:30:54

I'm just getting started on a project using boost libraries and I've got a
fair amount of code that could be cleaned up to be submitted - I'm also
interested in hearing if there is overlap in the existing libraries that I'm

Ideas (I have all of these in various states of completeness):

1. Generalize mem_fn, mem_fun, ptr_fun... into a single make_function()
which uses template specialization to return an appropriate function object.
Include functionality to construct a function object from a data member
(given an object, returns the value of the data member).

1.1 Use make_function() to implement smarter versions of std algorithm
functions that don't require adaptors for many parameters.

2. Copy-on-write smart pointer. Useful in implementing data-types
efficiently with value semantics.

3. Transactional STL style containers - uses non-throwing swap member of
contained items to achieve efficient transactional operations.

4. Generalized notion of range to a single "object". A range is an
encapsulation of a pair of iterators (i.e. [iter1, iter2) is a range ). An
array constitutes a range as do any of the STL containers. Push ranges
through the STL containers and the algorithms.

5. Some utility algorithms - for example, I have a template function
lookup(Range, Conv, Value). Takes a range (as described above), a conversion
function (which takes an item in the range and converts it to a value) and a
value. lookup performs a linear search similar to find and return an
iterator to an item in the range for wish Conv(item) == Value. You can use
it like this:

typedef std::pair<int, std::string> int_float;
int_float arr[] = {
    int_float(10, "Mark"),
    int_float(5, "Dave"),
    int_float(3, "John")
std::cout << lookup(arr, &int_float::first, 5) << std::endl;
std::cout << lookup(arr, &int_float::second, std::string("John")) <<
This prints:
You can call lookup with any range as the first parameter (any STL container
will work) and anything that can generate a conversion function with
make_function() - i.e. pointer to a member function, and external function,
a function object constructed with compose...
I have to run now so I'll stop here - just trying to gauge interest and get
Sean Parent
Sr. Computer Scientist II
Advanced Technology Group
Adobe Systems Incorporated

Boost list run by bdawes at, gregod at, cpdaniel at, john at