-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
adcb15f
commit 9628891
Showing
5 changed files
with
171 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Modified for https://github.com/morzhovets/momo project. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
|
||
template <class Map, class ValueTp, class PtrT, class CPtrT> | ||
void testMap() { | ||
typedef typename Map::difference_type Diff; | ||
{ | ||
#ifdef LIBCPP_HAS_BAD_NEWS_FOR_MOMO | ||
typedef typename Map::iterator It; | ||
#else | ||
typedef std::iterator_traits<typename Map::iterator> It; | ||
#endif | ||
#ifdef LIBCPP_HAS_BAD_NEWS_FOR_MOMO | ||
static_assert((std::is_same<typename It::value_type, ValueTp>::value), ""); | ||
static_assert((std::is_same<typename It::reference, ValueTp&>::value), ""); | ||
static_assert((std::is_same<typename It::pointer, PtrT>::value), ""); | ||
#endif | ||
static_assert((std::is_same<typename It::difference_type, Diff>::value), ""); | ||
} | ||
{ | ||
#ifdef LIBCPP_HAS_BAD_NEWS_FOR_MOMO | ||
typedef typename Map::const_iterator It; | ||
#else | ||
typedef std::iterator_traits<typename Map::const_iterator> It; | ||
#endif | ||
#ifdef LIBCPP_HAS_BAD_NEWS_FOR_MOMO | ||
static_assert((std::is_same<typename It::value_type, ValueTp>::value), ""); | ||
static_assert((std::is_same<typename It::reference, ValueTp const&>::value), ""); | ||
static_assert((std::is_same<typename It::pointer, CPtrT>::value), ""); | ||
#endif | ||
static_assert((std::is_same<typename It::difference_type, Diff>::value), ""); | ||
} | ||
} | ||
|
||
|
||
int main(int, char**) { | ||
{ | ||
typedef std::multimap<int, int> Map; | ||
typedef std::pair<const int, int> ValueTp; | ||
testMap<Map, ValueTp, ValueTp*, ValueTp const*>(); | ||
} | ||
{ | ||
typedef std::pair<const int, int> ValueTp; | ||
typedef test_allocator<ValueTp> Alloc; | ||
typedef std::multimap<int, int, std::less<int>, Alloc> Map; | ||
testMap<Map, ValueTp, ValueTp*, ValueTp const*>(); | ||
} | ||
#if TEST_STD_VER >= 11 | ||
{ | ||
typedef std::pair<const int, int> ValueTp; | ||
typedef min_allocator<ValueTp> Alloc; | ||
typedef std::multimap<int, int, std::less<int>, Alloc> Map; | ||
testMap<Map, ValueTp, min_pointer<ValueTp>, min_pointer<const ValueTp>>(); | ||
} | ||
#endif | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test/sources/libcxx/multimap/multimap.ops/contains_transparent.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Modified for https://github.com/morzhovets/momo project. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// UNSUPPORTED: c++03, c++11, c++14, c++17 | ||
|
||
// <map> | ||
|
||
// template<class K> bool contains(const K& x) const; // C++20 | ||
|
||
struct Comp { | ||
using is_transparent = void; | ||
|
||
bool operator()(const std::pair<int, int>& lhs, | ||
const std::pair<int, int>& rhs) const { | ||
return lhs < rhs; | ||
} | ||
|
||
bool operator()(const std::pair<int, int>& lhs, int rhs) const { | ||
return lhs.first < rhs; | ||
} | ||
|
||
bool operator()(int lhs, const std::pair<int, int>& rhs) const { | ||
return lhs < rhs.first; | ||
} | ||
}; | ||
|
||
template <typename Container> | ||
void test() { | ||
Container s{{{2, 1}, 1}, {{1, 2}, 2}, {{1, 3}, 3}, {{1, 4}, 4}, {{2, 2}, 5}}; | ||
|
||
assert(s.contains(1)); | ||
assert(!s.contains(-1)); | ||
} | ||
|
||
int main(int, char**) { | ||
test<std::multimap<std::pair<int, int>, int, Comp> >(); | ||
|
||
return 0; | ||
} |