25 #include <type_traits> 37 using Container = std::deque<T>;
40 std::size_t gDefaultCtrCnt;
41 std::size_t gCopyCtrCnt;
42 std::size_t gMoveCtrCnt;
43 std::size_t gExplicitCtrCnt;
44 std::size_t gMultiargCtrCnt;
45 std::size_t gCopyOpCnt;
46 std::size_t gMoveOpCnt;
47 std::size_t gConvertOpCnt;
66 explicit Object(
int,
int) {
69 Object& operator=(
const Object&) {
86 void init_counters() {
87 gDefaultCtrCnt = gCopyCtrCnt = gMoveCtrCnt = gExplicitCtrCnt =
88 gMultiargCtrCnt = gCopyOpCnt = gMoveOpCnt = gConvertOpCnt = 0;
94 template <
typename Iterator>
110 template <
typename Iterator>
111 void emplace_test(Container<Object>& q, Iterator it) {
124 it = std::make_pair(0, 0);
128 it =
const_cast<const decltype(args)&
>(args);
133 auto args3 = std::make_pair(0, 0);
148 using namespace folly;
153 TEST(EmplaceIterator, EmplacerTest) {
160 emplace_test(q,
emplacer(q, q.begin()));
171 EXPECT_EQ(q, Container<int>({3, 4, 0, 1, 2}));
178 TEST(EmplaceIterator, FrontEmplacerTest) {
196 EXPECT_EQ(q, Container<int>({4, 3, 2, 1, 0}));
203 TEST(EmplaceIterator, BackEmplacerTest) {
221 EXPECT_EQ(q, Container<int>({0, 1, 2, 3, 4}));
228 TEST(EmplaceIterator, HintEmplacerTest) {
231 std::map<int, Object>
m;
234 std::piecewise_construct,
235 std::forward_as_tuple(0),
236 std::forward_as_tuple(0));
238 std::piecewise_construct,
239 std::forward_as_tuple(1),
240 std::forward_as_tuple(0, 0));
242 std::piecewise_construct,
243 std::forward_as_tuple(2),
244 std::forward_as_tuple(Object{}));
257 explicit O(
int i_) :
i(i_) {}
266 std::vector<int> v1 = {0, 1, 2, 3, 4};
267 std::vector<int> v2 = {0, 2, 4};
275 std::set<O> expected = {O(1), O(3)};
287 Container<int> in({0, 1, 2});
288 Container<Object> out;
305 TEST(EmplaceIterator, Transform) {
307 Container<int> in({0, 1, 2});
308 Container<Object> out;
326 TEST(EmplaceIterator, EmplaceArgs) {
330 const Object& o4 = o3;
364 0, o1, o2, o3, o4, Object{}, std::cref(o2),
rref(
std::move(o5)));
404 std::tuple_element_t<0, decltype(args)::storage_type>>::
value,
409 std::tuple_element_t<1, decltype(args)::storage_type>>::
value,
414 std::tuple_element_t<2, decltype(args)::storage_type>>::
value,
419 std::tuple_element_t<3, decltype(args)::storage_type>>::
value,
424 std::tuple_element_t<4, decltype(args)::storage_type>>::
value,
429 std::tuple_element_t<5, decltype(args)::storage_type>>::
value,
433 std::reference_wrapper<const Object>,
434 std::tuple_element_t<6, decltype(args)::storage_type>>::
value,
439 std::tuple_element_t<7, decltype(args)::storage_type>>::
value,
445 std::is_same<
int&&, decltype(get_emplace_arg<0>(
std::move(args)))>::
449 std::is_same<Object&, decltype(get_emplace_arg<1>(
std::move(args)))>::
458 std::is_same<Object&, decltype(get_emplace_arg<3>(
std::move(args)))>::
467 std::is_same<Object&&, decltype(get_emplace_arg<5>(
std::move(args)))>::
476 std::is_same<Object&&, decltype(get_emplace_arg<7>(
std::move(args)))>::
485 std::is_same<
int&, decltype(get_emplace_arg<0>(args))>::
value,
"");
487 std::is_same<Object&, decltype(get_emplace_arg<1>(args))>::
value,
"");
489 std::is_same<Object&, decltype(get_emplace_arg<2>(args))>::
value,
"");
491 std::is_same<Object&, decltype(get_emplace_arg<3>(args))>::
value,
"");
493 std::is_same<Object&, decltype(get_emplace_arg<4>(args))>::
value,
"");
495 std::is_same<Object&, decltype(get_emplace_arg<5>(args))>::
value,
"");
497 std::is_same<
const Object&, decltype(get_emplace_arg<6>(args))>::
value,
505 TEST(EmplaceIterator, ImplicitUnpack) {
506 static std::size_t multiCtrCnt;
507 static std::size_t pairCtrCnt;
508 static std::size_t tupleCtrCnt;
514 explicit Object2(
const std::pair<int, int>&) {
517 explicit Object2(
const std::tuple<int, int>&) {
522 auto test = [](
auto&& it,
bool expectUnpack) {
523 multiCtrCnt = pairCtrCnt = tupleCtrCnt = 0;
524 it = std::make_pair(0, 0);
537 Container<Object2> q;
540 test(emplacer<false>(q, q.begin()),
false);
542 test(front_emplacer<false>(q),
false);
544 test(back_emplacer<false>(q),
false);
bool operator==(const char *c, CStringRange::Sentinel)
emplace_iterator< Container, implicit_unpack > emplacer(Container &c, typename Container::iterator i)
#define ASSERT_EQ(val1, val2)
front_emplace_iterator< Container, implicit_unpack > front_emplacer(Container &c)
#define EXPECT_EQ(val1, val2)
static uint64_t test(std::string name, bool fc_, bool dedicated_, bool tc_, bool syncops_, uint64_t base)
constexpr detail::Map< Move > move
back_emplace_iterator< Container, implicit_unpack > back_emplacer(Container &c)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
PUSHMI_INLINE_VAR constexpr detail::transform_fn transform
hint_emplace_iterator< Container, implicit_unpack > hint_emplacer(Container &c, typename Container::iterator i)
constexpr std::decay< T >::type copy(T &&value) noexcept(noexcept(typename std::decay< T >::type(std::forward< T >(value))))
rvalue_reference_wrapper< T > rref(T &&value) noexcept
static map< string, int > m
static const char *const value
TEST(EmplaceIterator, EmplacerTest)
emplace_args< Args... > make_emplace_args(Args &&...args) noexcept(noexcept(emplace_args< Args... >(std::forward< Args >(args)...)))
uint64_t diff(uint64_t a, uint64_t b)
void copy_and_move_test()
std::enable_if< IsLessThanComparable< Value >::value, bool >::type operator<(const Expected< Value, Error > &lhs, const Expected< Value, Error > &rhs)