$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] does composite_key_compare support an interface that enables comparsion of the whole tuple
From: brijesh.sharma_at_[hidden]
Date: 2011-06-13 13:54:28
Hi,
 
Here is what I am trying to do
typedef DWORD DSIid;
enum DSType
{
  DSTypeNone = 0,
  DSTypeBegin,
  DSTypeRoot
}
                
struct SDSIOwnedByKey
{
                SDSIOwnedByKey(DSType DSTypeOwned, DSIid DSIidOwned,
DSType DSTypeOwner, DSIid DSIidOwner)
                                : m_DSTypeOwned(DSTypeOwned),
m_DSIidOwned(DSIidOwned), m_DSTypeOwner(DSTypeOwner),
m_DSIidOwner(DSIidOwner)
                {
                }
 
                bool operator == (const SDSIOwnedByKey &rcComp) const
                {
                                return m_DSTypeOwned ==
rcComp.m_DSTypeOwned && 
                                                m_DSIidOwned ==
rcComp.m_DSIidOwned &&
                                                m_DSTypeOwner ==
rcComp.m_DSTypeOwner && 
                                                m_DSIidOwner ==
rcComp.m_DSIidOwner;
                }
DSType m_DSTypeOwned;
       DSIid         m_DSIidOwned; 
       DSType m_DSTypeOwner;
       DSIid         m_DSIidOwner; 
};             
 
class DataStore
{
typedef boost::multi_index_container<
    SDSIOwnedByKey,
    boost::multi_index::indexed_by<
 
boost::multi_index::ordered_unique<boost::multi_index::tag<ByOwnedTypeOw
nerTypeOwnerIdOwnedId>,
    boost::multi_index::composite_key<SDSIOwnedByKey,  
    boost::multi_index::member<SDSIOwnedByKey, DSType,
&SDSIOwnedByKey::m_DSTypeOwned>,
    boost::multi_index::member<SDSIOwnedByKey, DSType,
&SDSIOwnedByKey::m_DSTypeOwner>,
    boost::multi_index::member<SDSIOwnedByKey, DSIid,
&SDSIOwnedByKey::m_DSIidOwner>,
    boost::multi_index::member<SDSIOwnedByKey, DSIid,
&SDSIOwnedByKey::m_DSIidOwned>
    >,
boost::multi_index::composite_key_compare<std::less<DSType>,std::less<DS
Type>, std::less<DSIid>, std::greater<DSIid>>
    >
    >
  > TOwnedBySort;
 
  typedef typename
TOwnedBySort::index<ByOwnedTypeOwnerTypeOwnerIdOwnedId>::type
OwnedBySort_ByOwnedTypeOwnerTypeOwnerId;
 
  TOwnedBySort m_oOwnedBySort;
 
};
 
 
Instead of 
    >,
boost::multi_index::composite_key_compare<std::less<DSType>,std::less<DS
Type>, std::less<DSIid>, std::greater<DSIid>>
 
I want to write a compare function that compared all the values in one
function, like a complete record comparison something like
 
    >, boost::multi_index::composite_key_compare<SDSIOwnedByKey>
And have an appropriate function which would get the whole record to
compare
 
Thanks
Brijesh