|
Boost Users : |
From: darren.gilbert_at_[hidden]
Date: 2004-12-16 14:21:23
Hello,
I was using the boost tuples library (from boost 1.31) to create a cache key. However, the Solaris compiler (SUNWspro v6.2.p1) complained when I tried to access the last element in the tuple. My class looked something like this:
typedef enum result_type_id {
...
} ResultTypeID;
class ParamStateKey;
class Cache
{
typedef boost::tuple<ParamStateKey, ResultTypeID, int, int, int> key_type;
// cache implementation
...
// some helper functions defined to hide the boost::tuple interface
static ParamStateKey &GetState(key_type &k) { return boost::tuples::get<0>(k); }
static ResultTypeID &GetGreek(key_type &k) { return boost::tuples::get<1>(k); }
static int &GetProduct(key_type &k) { return boost::tuples::get<2>(k); }
static int &GetSubpage(key_type &k) { return boost::tuples::get<3>(k); }
static int &GetBucket(key_type &k) { return boost::tuples::get<4>(k); }
static key_type MakeKey(const ParamStateKey &psk, ResultTypeID r, int p1, int p2, int bkt)
{
return boost::tuples::make_tuple(psk, r, p1, p2, bkt);
}
};
The solaris compiler complained whenever I tried to call Cache::GetBucket() with the following error:
"../../../../incl/3rd/boost/tuple/detail/tuple_basic.hpp", line 105: Error: Could not find a match for boost::tuples::detail::get_class<0>::get<boost::tuples::detail::get_class<0>::RET, boost::tuples::detail::get_class<0>::HT, boost::tuples::detail::get_class<0>::TT>(boost::tuples::cons<int, boost::tuples::null_type>).
"../../../../incl/3rd/boost/tuple/detail/tuple_basic.hpp", line 105: Where: While instantiating "static boost::tuples::detail::get_class<1>::get<int&, int, boost::tuples::cons<int, boost::tuples::null_type>>(boost::tuples::cons<int, boost::tuples::cons<int, boost::tuples::null_type>>&)".
"../../../../incl/3rd/boost/tuple/detail/tuple_basic.hpp", line 105: Where: Instantiated from non-template code.
Firstly, I have no way of deciphering that error message. Through trial and error, I found that removing the GetBucket() calls solved the problem. However, I needed these calls. I reasoned that since the other helper functions worked, it was a problem accessing the last element of the tuple. So I created a dummy entry in the tuple and redefined my typedef:
typedef boost::tuple<ParamStateKey, ResultTypeID, int, int, int, int> key_type;
This work-around is fine, so this is not an urgent problem. But it seems like this should not be necessary.
________________________________________
Darren Gilbert
Associate Director
UBS - Equities Quantitative Strategies
Phone: +1 (312) 525-5766
Stein's law: "When a trend cannot continue it will stop."
-- Herb Stein, Chairman of the Council of Economic Advisors under Nixon
Visit our website at http://www.ubs.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net