$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [chrono][stopwatches] Request for interest in NEW stopwatch/timer reporting facilities
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2011-09-15 14:52:38
Le 15/09/11 15:03, Steven Maitlall a écrit :
> I like the ideas you put forth here.
Thanks.
> Though, I wonder if it could be taken a few steps further ... A boost
> formatting library
>
> 81 typedef boost::format::context_adapter<
> 82 struct timeval,
> 83 boost::format::context_spec<
> 84 boost::format::context_element<'d', ...>
> 85> > timeval_context_t;
> 86
> 87 boost::format::basic_formatter<timeval_context_t> fmt;
> 88
> 89 struct timeval tv;
> 90 gettimeofday(&tv, NULL);
> 91
> 92 // Standard usage
> 93 std::cout<< fmt("%d:%d",tv.tv_sec, tv.tv_usec)<< std::endl;
> 94
> 95 // Output the first, then the second context elements
> 96 std::cout<< fmt("%{1}:%{2}",tv)<< std::endl;
>
> I like where the idea is taking me and I'm working on the implementation
> details now
>
>
>
IUC what you want to achieve is to format a UDT using its parts. I think
that seen the UDT as a tuple could help. What about using the {i,j} to
refer to the j-th part of the i-th parameter? In this way you could mix
several parameter with the same format.
std::cout<< fmt("{1,1}:{1,2} = {2}") % tv % i;
I think I start to see how such a library could help to make easier the
Stopwatch reporting. I would be greatfull if you could explain how this
can be applied in my context.
Thanks,
Vicente