74 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++0310 11// <list>12 13// template <class... Args> void emplace(const_iterator p, Args&&... args); // constexpr since C++2614 15#include <list>16#include <cassert>17 18#include "test_macros.h"19#include "min_allocator.h"20 21class A {22 int i_;23 double d_;24 25 A(const A&);26 A& operator=(const A&);27 28public:29 TEST_CONSTEXPR_CXX20 A(int i, double d) : i_(i), d_(d) {}30 31 TEST_CONSTEXPR int geti() const { return i_; }32 TEST_CONSTEXPR double getd() const { return d_; }33};34 35TEST_CONSTEXPR_CXX26 bool test() {36 {37 std::list<A> c;38 c.emplace(c.cbegin(), 2, 3.5);39 assert(c.size() == 1);40 assert(c.front().geti() == 2);41 assert(c.front().getd() == 3.5);42 c.emplace(c.cend(), 3, 4.5);43 assert(c.size() == 2);44 assert(c.front().geti() == 2);45 assert(c.front().getd() == 3.5);46 assert(c.back().geti() == 3);47 assert(c.back().getd() == 4.5);48 }49 {50 std::list<A, min_allocator<A>> c;51 c.emplace(c.cbegin(), 2, 3.5);52 assert(c.size() == 1);53 assert(c.front().geti() == 2);54 assert(c.front().getd() == 3.5);55 c.emplace(c.cend(), 3, 4.5);56 assert(c.size() == 2);57 assert(c.front().geti() == 2);58 assert(c.front().getd() == 3.5);59 assert(c.back().geti() == 3);60 assert(c.back().getd() == 4.5);61 }62 63 return true;64}65 66int main(int, char**) {67 assert(test());68#if TEST_STD_VER >= 2669 static_assert(test());70#endif71 72 return 0;73}74