mirror of
https://github.com/ETLCPP/etl.git
synced 2026-10-28 18:07:10 +08:00
Set default compare for iconst_map (#1560)
This is consistent with (i)flat_map, and allows to just write iconst_map<K, V>. Add tests, also fix iconst_set.
This commit is contained in:
parent
e25a44195c
commit
a547336322
@ -48,7 +48,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace etl
|
namespace etl
|
||||||
{
|
{
|
||||||
template <typename TKey, typename TMapped, typename TKeyCompare>
|
template <typename TKey, typename TMapped, typename TKeyCompare = etl::less<TKey>>
|
||||||
class iconst_map
|
class iconst_map
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -48,7 +48,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace etl
|
namespace etl
|
||||||
{
|
{
|
||||||
template <typename TKey, typename TKeyCompare>
|
template <typename TKey, typename TKeyCompare = etl::less<TKey>>
|
||||||
class iconst_set
|
class iconst_set
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -112,6 +112,9 @@ namespace
|
|||||||
using mapped_type = Data::mapped_type;
|
using mapped_type = Data::mapped_type;
|
||||||
using const_iterator = Data::const_iterator;
|
using const_iterator = Data::const_iterator;
|
||||||
|
|
||||||
|
static_assert(etl::is_same<etl::iconst_map<key_type, mapped_type>, etl::iconst_map<key_type, mapped_type, etl::less<key_type>>>::value,
|
||||||
|
"default compare is not less");
|
||||||
|
|
||||||
SUITE(test_const_map)
|
SUITE(test_const_map)
|
||||||
{
|
{
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|||||||
@ -111,6 +111,9 @@ namespace
|
|||||||
using mapped_type = Data::mapped_type;
|
using mapped_type = Data::mapped_type;
|
||||||
using const_iterator = Data::const_iterator;
|
using const_iterator = Data::const_iterator;
|
||||||
|
|
||||||
|
static_assert(etl::is_same<etl::iconst_multimap<key_type, mapped_type>, etl::iconst_multimap<key_type, mapped_type, etl::less<key_type>>>::value,
|
||||||
|
"default compare is not less");
|
||||||
|
|
||||||
SUITE(test_const_multimap)
|
SUITE(test_const_multimap)
|
||||||
{
|
{
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|||||||
@ -114,6 +114,9 @@ namespace
|
|||||||
using key_type = Data::key_type;
|
using key_type = Data::key_type;
|
||||||
using const_iterator = Data::const_iterator;
|
using const_iterator = Data::const_iterator;
|
||||||
|
|
||||||
|
static_assert(etl::is_same<etl::iconst_multiset<key_type>, etl::iconst_multiset<key_type, etl::less<key_type>>>::value,
|
||||||
|
"default compare is not less");
|
||||||
|
|
||||||
SUITE(test_const_multiset)
|
SUITE(test_const_multiset)
|
||||||
{
|
{
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|||||||
@ -112,6 +112,8 @@ namespace
|
|||||||
using key_type = Data::key_type;
|
using key_type = Data::key_type;
|
||||||
using const_iterator = Data::const_iterator;
|
using const_iterator = Data::const_iterator;
|
||||||
|
|
||||||
|
static_assert(etl::is_same<etl::iconst_set<key_type>, etl::iconst_set<key_type, etl::less<key_type>>>::value, "default compare is not less");
|
||||||
|
|
||||||
SUITE(test_const_set)
|
SUITE(test_const_set)
|
||||||
{
|
{
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|||||||
@ -211,6 +211,8 @@ namespace
|
|||||||
// return os;
|
// return os;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
static_assert(etl::is_same<etl::iflat_map<int, D1>, etl::iflat_map<int, D1, etl::less<int>>>::value, "default compare is not less");
|
||||||
|
|
||||||
SUITE(test_flat_map)
|
SUITE(test_flat_map)
|
||||||
{
|
{
|
||||||
NDC N0 = NDC("A");
|
NDC N0 = NDC("A");
|
||||||
|
|||||||
@ -239,6 +239,8 @@ namespace
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assert(etl::is_same<etl::iflat_multimap<int, D1>, etl::iflat_multimap<int, D1, etl::less<int>>>::value, "default compare is not less");
|
||||||
|
|
||||||
SUITE(test_flat_multimap)
|
SUITE(test_flat_multimap)
|
||||||
{
|
{
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|||||||
@ -241,6 +241,8 @@ namespace
|
|||||||
|
|
||||||
std::vector<int> int_data;
|
std::vector<int> int_data;
|
||||||
|
|
||||||
|
static_assert(etl::is_same<etl::iflat_multiset<int>, etl::iflat_multiset<int, etl::less<int>>>::value, "default compare is not less");
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
struct SetupFixture
|
struct SetupFixture
|
||||||
{
|
{
|
||||||
|
|||||||
@ -261,6 +261,8 @@ namespace
|
|||||||
return (lhs.value < rhs.k.value);
|
return (lhs.value < rhs.k.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_assert(etl::is_same<etl::iflat_set<int>, etl::iflat_set<int, etl::less<int>>>::value, "default compare is not less");
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
struct SetupFixture
|
struct SetupFixture
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user