$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] [boost-users][Milti-Index] labmda and composite key
From: Igor R (boost.lists_at_[hidden])
Date: 2009-01-08 15:07:04
Hello,
I've got the following data structure:
struct Service;
typedef shared_ptr<Service> ServicePtr;
struct Event
{
  ServicePtr service() const;
  ptime time() const;
};
typedef shared_ptr<Event> EventPtr;
struct Cache
{
        struct time_tag{};
        typedef mi::multi_index_container<
                EventPtr,
                mi::indexed_by<
                        mi::ordered_non_unique<
                          mi::tag<time_tag>,
                                mi::composite_key<
                                        EventPtr,
                                        mi::const_mem_fun<Event, ServicePtr, &Event::service>
                                        mi::const_mem_fun<Event, pt::ptime, &Event::time>
				>
			>
		>
	> type;
        typedef type::index<time_tag>::type ByTime;
};
Cache cache_;
ServicePtr servicePtr = ...;
period = ...;
I try to extract all the events belonging to some service and bounded
by "period":
namespace bl=boost::lambda;
pair<Cache::type::iterator, Cache::type::iterator> byPeriod =
  cache_.get<Cache::time_tag>().range(bl::_1 >= make_tuple(servicePtr,
period.begin()), bl::_1 <= make_tuple(servicePtr, period.last()));
The cache contains lots of matching events, but for some reason, this
expression always returs empty region, i.e.
byPeriod.first==byPeriod.second.
So I'd like to know if the above expression is correct or I'm doing
something wrong?
Thank you.