OTest2
A C++ testing framework
|
Go to the documentation of this file.
20 #ifndef OTest2_INCLUDE_OTEST2_CONTAINERTRAIT_H_
21 #define OTest2_INCLUDE_OTEST2_CONTAINERTRAIT_H_
24 #include <unordered_map>
44 template<
typename Container_>
49 static typename Container_::const_iterator
begin(
50 const Container_& cont_) {
57 static typename Container_::const_iterator
end(
58 const Container_& cont_) {
65 template<
typename Type_>
68 template<
typename T_>
struct SfinaeCheck :
public std::true_type {};
71 static auto test_fce(
void*) -> SfinaeCheck<decltype(&T_::key_comp)>;
73 static std::false_type test_fce(...);
76 static constexpr
bool value = decltype(test_fce<Type_>(
nullptr))::
value;
79 template<
typename Container_>
84 typedef typename Container_::key_type
KeyType;
97 const Container_& cont_) {
105 const Container_& cont_) {
113 const Container_& cont_,
115 return cont_.equal_range(key_);
119 template<
typename Container_,
bool key_comp_>
122 template<
typename Container_>
129 const Container_& cont_,
132 return !cont_.key_comp()(a_key_, b_key_) && !cont_.key_comp()(b_key_, a_key_);
136 template<
typename Container_>
143 const Container_& cont_,
146 return cont_.key_eq()(a_key_, b_key_);
166 template<
typename Container_>
169 Container_, Private::HasContainerKeyComp<Container_>::value> {};
static const_iterator end(const Container_ &cont_)
Get ending iterator.
static bool keyEqual(const Container_ &cont_, typename TypeTrait< typename MapTraitImplCommon< Container_ >::KeyType >::BestArg a_key_, typename TypeTrait< typename MapTraitImplCommon< Container_ >::KeyType >::BestArg b_key_)
Compare equality of two keys.
Container_::mapped_type ValueType
Type of the mapped value.
Private::SelectArgType< Type_, std::is_scalar< Type_ >::value >::Value BestArg
static Container_::const_iterator end(const Container_ &cont_)
Get ending iterator.
Generic type trait used by the framework.
static std::pair< const_iterator, const_iterator > equalRange(const Container_ &cont_, typename TypeTrait< KeyType >::BestArg key_)
Get range of items with the same key.
static Container_::const_iterator begin(const Container_ &cont_)
Get beginning iterator.
static const_iterator begin(const Container_ &cont_)
Get the beginning forward iterator.
A trait for access to a map container.
A simple trait allowing access to list container's iterators.
static constexpr bool value
Container_::key_type KeyType
Type of the key.
static bool keyEqual(const Container_ &cont_, typename TypeTrait< typename MapTraitImplCommon< Container_ >::KeyType >::BestArg a_key_, typename TypeTrait< typename MapTraitImplCommon< Container_ >::KeyType >::BestArg b_key_)
Compare equality of two keys.
Container_::const_iterator const_iterator