|
Boost : |
Subject: Re: [boost] [proto] _value doesn't enforce zero arity
From: troy d. straszheim (troy_at_[hidden])
Date: 2009-04-08 21:14:33
troy d. straszheim wrote:
> Now, per-class trace control (maybe via a trait?) this would be imho more useful.
>
Here's a possible interface for a boost::mpl-ized version of Steven
Watanabe's template_profiler:
#define BOOST_MPL_ENABLE_TRACE
#include "trace.hpp"
//
// classes peppered with traces
//
template <typename T>
struct traceme
{
BOOST_MPL_TRACE(traceme<T>);
};
template <typename T>
struct traceme_too
{
BOOST_MPL_TRACE(traceme_too<T>);
};
template <typename T>
struct dont_trace_me
{
BOOST_MPL_TRACE(dont_trace_me<T>);
};
//
// trace-enabling traits
//
namespace boost {
namespace mpl {
namespace trace {
template <typename T>
struct enable<traceme<T> > : boost::mpl::true_ { };
template <typename T>
struct enable<traceme_too<T> > : boost::mpl::true_ { };
}
}
}
//
// 3. profit
//
int main(int, char**)
{
traceme<int> ti;
dont_trace_me<float> dtmf;
traceme_too<void> tv;
}
The trace.hpp is attached, tested on gccs 4.3 and 4.2.
-t
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk