Boost logo

Boost :

From: Matus Chochlik (chochlik_at_[hidden])
Date: 2008-04-26 04:18:15


Hello,

I would like to announce that a new version of 'mirror' library is available
in the sandbox, at

http://svn.boost.org/svn/boost/sandbox/mirror/

with several new features, including:

- full_name() getter (returns the type or namespace name with nested
  name specifier), which works even for types like pointers etc.
- meta-type for std::pair<> (a meta-class allowing to inspect
  the attributes will be comming soon)

// this means that you can now define a type T like this:

using namespace ::std;
using namespace ::boost;
using namespace ::boost::mirror;
//
typedef pair<const int*, double [321]> T1;
typedef pair<float, const long&> T2;
typedef pair<T1 const volatile, T2 volatile const> T3;
typedef pair<T2, T1 volatile> T4;
typedef pair<T3 const * volatile, const T4&> T;

// get the meta data
typedef BOOST_MIRROR_REFLECT_TYPE(T) meta_T;

// and query the base name (without nested type specifiers)
cout << meta_T::base_name();
/** printing out (newlines added):
 *
 pair< pair< pair< int const *, double [321] > const volatile,
 pair< float, long const & > const volatile > const * volatile,
 pair< pair< float, long const & >, pair< int const *,
 double [321] > volatile > const & >
 */

// or the full name
cout << meta_T::full_name();
/** printing out (newlines added):
 *
::std::pair< ::std::pair< ::std::pair< int const *,
double [321] > const volatile, ::std::pair< float,
long const & > const volatile > const * volatile,
::std::pair< ::std::pair< float, long const & >, ::std::pair
< int const *, double [321] > volatile > const & >
 */

Please see
http://svn.boost.org/svn/boost/sandbox/mirror/libs/examples/special/std_pair.cpp
for a complete example.

Since it has been tested only with MSVC++ 2008
there may be some problems compiling the samples with
other compilers (mainly missing typename keywords
here and there). Next week I'm going to fix this.

There are still no jamfiles nor makefiles so you'll have
to write some yourselves if you want to try the examples.
Sorry, I hope this'll be fixed soon, too.

Some of the other examples have been updated to show
the using of the full_name() function. See

http://svn.boost.org/svn/boost/sandbox/mirror/libs/examples/registering/

For those interested, there is also an example, showing
how to use mirror with Boost.Serialization at:

http://svn.boost.org/svn/boost/sandbox/mirror/libs/examples/serialization/cube.cpp

It is rather clumsy and currently it can't be compiled
with gcc (I couldn't find the reason why yet).
Note that it's just a first shot and most of the code ensuring
the cooperation with Boost.Serialization will be rewritten and
hidden in a header file in the future.

Best,
-- matus


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