[accumulators] Help required for using UDT as Sample
Hi, I am using boost::accumulator for finding min (among other things). It works fine when I use a POD as Sample. ex: accumulator_set< double, features tag::min > acc; acc(1.0); acc(5.0); .... I have my own data type, time stamp and value. I would like to get the min Sample with corresponding time stamp. class time_val { public: time_t _time; double _value; /* I have overloaded operators: <, >, ==, != */ /* Have provided copy constructor */ }; When I try: accumulator_set< time_val, features tag::min > acc; I get a whole lot of compilation errors. Is there any way I can make a UDT as a sample? regards, -dhruva Bollywood news, movie reviews, film trailers and more! Go to http://in.movies.yahoo.com/
dhruva wrote:
I have my own data type, time stamp and value. I would like to get the min Sample with corresponding time stamp.
class time_val { public: time_t _time; double _value;
/* I have overloaded operators: <, >, ==, != */ /* Have provided copy constructor */ };
When I try: accumulator_set< time_val, features tag::min > acc;
I get a whole lot of compilation errors. Is there any way I can make a UDT as a sample?
That should just work. Can you provide a complete example? -- Eric Niebler BoostPro Computing http://www.boostpro.com
Hello,
Thank you for offering to have a look, here is the code.
regards,
-dhruva
// Starts here
#include
From: Eric Niebler
To: boost-users@lists.boost.org Sent: Wednesday, 25 February, 2009 10:37:42 AM Subject: Re: [Boost-users] [accumulators] Help required for using UDT as Sample dhruva wrote:
I have my own data type, time stamp and value. I would like to get the min Sample with corresponding time stamp.
class time_val { public: time_t _time; double _value;
/* I have overloaded operators: <, >, ==, != */ /* Have provided copy constructor */ };
When I try: accumulator_set< time_val, features > acc;
I get a whole lot of compilation errors. Is there any way I can make a UDT as a sample?
That should just work. Can you provide a complete example?
-- Eric Niebler BoostPro Computing http://www.boostpro.com _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/
Apologies for all the noise, I found my coding error. The operator overloading had to be 'const'. bool operator < (const acc_sample &rhs) const { return _data._value < rhs._data._value; } Instead of: bool operator < (const acc_sample &rhs) { return _data._value < rhs._data._value; } Thanks, -dhruva ----- Original Message ----
From: Eric Niebler
To: boost-users@lists.boost.org Sent: Wednesday, 25 February, 2009 10:37:42 AM Subject: Re: [Boost-users] [accumulators] Help required for using UDT as Sample dhruva wrote:
I have my own data type, time stamp and value. I would like to get the min Sample with corresponding time stamp.
class time_val { public: time_t _time; double _value;
/* I have overloaded operators: <, >, ==, != */ /* Have provided copy constructor */ };
When I try: accumulator_set< time_val, features > acc;
I get a whole lot of compilation errors. Is there any way I can make a UDT as a sample?
That should just work. Can you provide a complete example?
-- Eric Niebler BoostPro Computing http://www.boostpro.com _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/
participants (2)
-
dhruva
-
Eric Niebler