Boost-Graph
view release on metacpan or search on metacpan
include/boost/multi_index/composite_key.hpp view on Meta::CPAN
{
if(comp.get_head()(c.get_head()(v),vc.get_head()))return true;
if(comp.get_head()(vc.get_head(),c.get_head()(v)))return false;
return compare_ckey_cval<
BOOST_DEDUCED_TYPENAME KeyCons::tail_type,Value,
BOOST_DEDUCED_TYPENAME ValCons::tail_type,
BOOST_DEDUCED_TYPENAME CompareCons::tail_type
>::compare(c.get_tail(),v,vc.get_tail(),comp.get_tail());
}
static bool compare(
const ValCons& vc,const KeyCons& c,const Value& v,
const CompareCons& comp)
{
if(comp.get_head()(vc.get_head(),c.get_head()(v)))return true;
if(comp.get_head()(c.get_head()(v),vc.get_head()))return false;
return compare_ckey_cval<
BOOST_DEDUCED_TYPENAME KeyCons::tail_type,Value,
BOOST_DEDUCED_TYPENAME ValCons::tail_type,
BOOST_DEDUCED_TYPENAME CompareCons::tail_type
>::compare(vc.get_tail(),c.get_tail(),v,comp.get_tail());
}
};
template
<
typename KeyCons,typename Value,
typename ValCons,typename CompareCons
>
struct compare_ckey_cval:
mpl::if_<
mpl::or_<
is_same<KeyCons,tuples::null_type>,
is_same<ValCons,tuples::null_type>
>,
compare_ckey_cval_terminal<KeyCons,Value,ValCons,CompareCons>,
compare_ckey_cval_normal<KeyCons,Value,ValCons,CompareCons>
>::type
{
};
template<typename KeyCons,typename Value,typename HashCons>
struct hash_ckey; /* fwd decl. */
template<typename KeyCons,typename Value,typename HashCons>
struct hash_ckey_terminal
{
static std::size_t hash(
const KeyCons&,const Value&,const HashCons&,std::size_t carry)
{
return carry;
}
};
template<typename KeyCons,typename Value,typename HashCons>
struct hash_ckey_normal
{
static std::size_t hash(
const KeyCons& c,const Value& v,const HashCons& h,std::size_t carry=0)
{
/* same hashing formula as boost::hash_combine */
carry^=h.get_head()(c.get_head()(v))+0x9e3779b9+(carry<<6)+(carry>>2);
return hash_ckey<
BOOST_DEDUCED_TYPENAME KeyCons::tail_type,Value,
BOOST_DEDUCED_TYPENAME HashCons::tail_type
>::hash(c.get_tail(),v,h.get_tail(),carry);
}
};
template<typename KeyCons,typename Value,typename HashCons>
struct hash_ckey:
mpl::if_<
is_same<KeyCons,tuples::null_type>,
hash_ckey_terminal<KeyCons,Value,HashCons>,
hash_ckey_normal<KeyCons,Value,HashCons>
>::type
{
};
template<typename ValCons,typename HashCons>
struct hash_cval; /* fwd decl. */
template<typename ValCons,typename HashCons>
struct hash_cval_terminal
{
static std::size_t hash(const ValCons&,const HashCons&,std::size_t carry)
{
return carry;
}
};
template<typename ValCons,typename HashCons>
struct hash_cval_normal
{
static std::size_t hash(
const ValCons& vc,const HashCons& h,std::size_t carry=0)
{
carry^=h.get_head()(vc.get_head())+0x9e3779b9+(carry<<6)+(carry>>2);
return hash_cval<
BOOST_DEDUCED_TYPENAME ValCons::tail_type,
BOOST_DEDUCED_TYPENAME HashCons::tail_type
>::hash(vc.get_tail(),h.get_tail(),carry);
}
};
template<typename ValCons,typename HashCons>
struct hash_cval:
mpl::if_<
is_same<ValCons,tuples::null_type>,
hash_cval_terminal<ValCons,HashCons>,
hash_cval_normal<ValCons,HashCons>
>::type
{
};
} /* namespace multi_index::detail */
/* composite_key_result */
template<typename CompositeKey>
( run in 1.054 second using v1.01-cache-2.11-cpan-39bf76dae61 )