52 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03 && !stdlib=libc++10 11// <vector>12 13// Validate various member functions of std::vector with an ADL-hijacking operator&14 15#include <vector>16#include <utility>17 18#include "operator_hijacker.h"19#include "test_iterators.h"20 21using Vector = std::vector<operator_hijacker>;22 23void test(24 Vector v, Vector::const_iterator it, cpp17_input_iterator<operator_hijacker*> other_it, operator_hijacker val) {25 // emplace / insert26 v.emplace(it);27 v.insert(it, it, it);28 v.insert(it, other_it, other_it);29 v.insert(it, operator_hijacker());30 v.insert(it, 1, val);31 v.insert(it, val);32 33 // erase34 v.erase(it);35 v.erase(it, it);36 37 // assignment38 v = static_cast<Vector&>(v);39 v = std::move(v);40 41 // construction42 {43 Vector v2(std::move(v));44 }45 {46 Vector v2(std::move(v), std::allocator<operator_hijacker>());47 }48 49 // swap50 v.swap(v);51}52