153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow//===----------------------------------------------------------------------===// 253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// 353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// The LLVM Compiler Infrastructure 453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// 553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// This file is dual licensed under the MIT and the University of Illinois Open 653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// Source Licenses. See LICENSE.TXT for details. 753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// 853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow//===----------------------------------------------------------------------===// 953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 10d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow#ifndef NASTY_CONTAINERS_H 11d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow#define NASTY_CONTAINERS_H 1253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 13d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow#include <cassert> 1453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#include <vector> 1553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#include <list> 1653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 17159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier#include "test_macros.h" 18159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier 1953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clowtemplate <class T> 2053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clowclass nasty_vector 2153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow{ 2253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clowpublic: 2353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename std::vector<T> nested_container; 2453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::value_type value_type; 2553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::reference reference; 2653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::const_reference const_reference; 2753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::iterator iterator; 2853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::const_iterator const_iterator; 2953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 3053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::size_type size_type; 3153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::difference_type difference_type; 3253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::pointer pointer; 3353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::const_pointer const_pointer; 3453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 3553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::reverse_iterator reverse_iterator; 3653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::const_reverse_iterator const_reverse_iterator; 3753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 3853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow nasty_vector() : v_() {} 3953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow explicit nasty_vector(size_type n) : v_(n) {} 4053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow nasty_vector(size_type n, const value_type& value) : v_(n, value) {} 4153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class InputIterator> nasty_vector(InputIterator first, InputIterator last) : v_(first, last) {} 42869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 4353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow nasty_vector(std::initializer_list<value_type> il) : v_(il) {} 4453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 4553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow ~nasty_vector() {} 4653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 4753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class InputIterator> 4853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void assign(InputIterator first, InputIterator last) { v_.assign(first, last); } 4953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void assign(size_type n, const value_type& u) { v_.assign(n, u); } 50869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 5153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void assign(std::initializer_list<value_type> il) { v_.assign(il); } 5253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 5353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 54159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier iterator begin() TEST_NOEXCEPT { return v_.begin(); } 55159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_iterator begin() const TEST_NOEXCEPT { return v_.begin(); } 56159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier iterator end() TEST_NOEXCEPT { return v_.end(); } 57159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_iterator end() const TEST_NOEXCEPT { return v_.end(); } 58159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier 59159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier reverse_iterator rbegin() TEST_NOEXCEPT { return v_.rbegin(); } 60159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_reverse_iterator rbegin() const TEST_NOEXCEPT { return v_.rbegin(); } 61159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier reverse_iterator rend() TEST_NOEXCEPT { return v_.rend(); } 62159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_reverse_iterator rend() const TEST_NOEXCEPT { return v_.rend(); } 63159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier 64159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_iterator cbegin() const TEST_NOEXCEPT { return v_.cbegin(); } 65159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_iterator cend() const TEST_NOEXCEPT { return v_.cend(); } 66159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_reverse_iterator crbegin() const TEST_NOEXCEPT { return v_.crbegin(); } 67159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_reverse_iterator crend() const TEST_NOEXCEPT { return v_.crend(); } 68159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier 69159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier size_type size() const TEST_NOEXCEPT { return v_.size(); } 70159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier size_type max_size() const TEST_NOEXCEPT { return v_.max_size(); } 71159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier size_type capacity() const TEST_NOEXCEPT { return v_.capacity(); } 72159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier bool empty() const TEST_NOEXCEPT { return v_.empty(); } 7353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void reserve(size_type n) { v_.reserve(n); }; 74159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier void shrink_to_fit() TEST_NOEXCEPT { v_.shrink_to_fit(); } 7553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 7653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow reference operator[](size_type n) { return v_[n]; } 7753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow const_reference operator[](size_type n) const { return v_[n]; } 7853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow reference at(size_type n) { return v_.at(n); } 7953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow const_reference at(size_type n) const { return v_.at(n); } 8053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 8153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow reference front() { return v_.front(); } 8253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow const_reference front() const { return v_.front(); } 8353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow reference back() { return v_.back(); } 8453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow const_reference back() const { return v_.back(); } 8553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 86159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier value_type* data() TEST_NOEXCEPT { return v_.data(); } 87159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const value_type* data() const TEST_NOEXCEPT { return v_.data(); } 8853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 8953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void push_back(const value_type& x) { v_.push_back(x); } 90869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 9153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void push_back(value_type&& x) { v_.push_back(std::forward<value_type&&>(x)); } 9253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class... Args> 9353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void emplace_back(Args&&... args) { v_.emplace_back(std::forward<Args>(args)...); } 9453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 9553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void pop_back() { v_.pop_back(); } 9653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 97869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 9853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class... Args> iterator emplace(const_iterator pos, Args&&... args) 9953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow { return v_.emplace(pos, std::forward<Args>(args)...); } 10053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 10184acb1ec3f7d5e0f37d7176697c2fa876c413407Eric Fiselier 10253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator insert(const_iterator pos, const value_type& x) { return v_.insert(pos, x); } 103869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 10453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator insert(const_iterator pos, value_type&& x) { return v_.insert(pos, std::forward<value_type>(x)); } 10553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 10653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator insert(const_iterator pos, size_type n, const value_type& x) { return v_.insert(pos, n, x); } 10753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class InputIterator> 10853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator insert(const_iterator pos, InputIterator first, InputIterator last) 10953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow { return v_.insert(pos, first, last); } 11053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 111869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 11253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator insert(const_iterator pos, std::initializer_list<value_type> il) { return v_.insert(pos, il); } 11353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 11453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 11553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator erase(const_iterator pos) { return v_.erase(pos); } 11653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator erase(const_iterator first, const_iterator last) { return v_.erase(first, last); } 11753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 118159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier void clear() TEST_NOEXCEPT { v_.clear(); } 11953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 12053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void resize(size_type sz) { v_.resize(sz); } 12153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void resize(size_type sz, const value_type& c) { v_.resize(sz, c); } 12253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 123159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier void swap(nasty_vector &nv) 124159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier#if TEST_STD_VER > 14 125159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier noexcept(std::is_nothrow_swappable<nested_container>::value) 126159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier#elif defined(_LIBCPP_VERSION) 127159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier TEST_NOEXCEPT_COND(std::__is_nothrow_swappable<nested_container>::value) 128159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier#endif 12953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow { v_.swap(nv.v_); } 13084acb1ec3f7d5e0f37d7176697c2fa876c413407Eric Fiselier 131d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow nasty_vector *operator &() { assert(false); return nullptr; } // nasty 132d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow const nasty_vector *operator &() const { assert(false); return nullptr; } // nasty 13384acb1ec3f7d5e0f37d7176697c2fa876c413407Eric Fiselier 13453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow nested_container v_; 13553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow}; 13653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 13753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clowtemplate <class T> 13853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clowbool operator==(const nasty_vector<T>& x, const nasty_vector<T>& y) { return x.v_ == y.v_; } 13953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 14053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clowtemplate <class T> 14153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clowclass nasty_list 14253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow{ 14353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clowpublic: 14453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 14553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename std::list<T> nested_container; 14653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::value_type value_type; 14753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::reference reference; 14853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::const_reference const_reference; 14953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::iterator iterator; 15053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::const_iterator const_iterator; 15153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 15253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::size_type size_type; 15353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::difference_type difference_type; 15453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::pointer pointer; 15553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::const_pointer const_pointer; 15653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 15753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::reverse_iterator reverse_iterator; 15853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow typedef typename nested_container::const_reverse_iterator const_reverse_iterator; 15953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 16053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow nasty_list() : l_() {} 16153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow explicit nasty_list(size_type n) : l_(n) {} 16253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow nasty_list(size_type n, const value_type& value) : l_(n,value) {} 16353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class Iter> 16453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow nasty_list(Iter first, Iter last) : l_(first, last) {} 165869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 16653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow nasty_list(std::initializer_list<value_type> il) : l_(il) {} 16753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 16853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 16953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow ~nasty_list() {} 17053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 171869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 17253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow nasty_list& operator=(std::initializer_list<value_type> il) { l_ = il; return *this; } 17353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 17453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class Iter> 17553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void assign(Iter first, Iter last) { l_.assign(first, last); } 17653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void assign(size_type n, const value_type& t) { l_.assign(n, t); } 177869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 17853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void assign(std::initializer_list<value_type> il) { l_.assign(il); } 17953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 18053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 18153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 182159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier iterator begin() TEST_NOEXCEPT { return l_.begin(); } 183159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_iterator begin() const TEST_NOEXCEPT { return l_.begin(); } 184159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier iterator end() TEST_NOEXCEPT { return l_.end(); } 185159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_iterator end() const TEST_NOEXCEPT { return l_.end(); } 18653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 187159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier reverse_iterator rbegin() TEST_NOEXCEPT { return l_.rbegin(); } 188159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_reverse_iterator rbegin() const TEST_NOEXCEPT { return l_.rbegin(); } 189159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier reverse_iterator rend() TEST_NOEXCEPT { return l_.rend(); } 190159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_reverse_iterator rend() const TEST_NOEXCEPT { return l_.rend(); } 19153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 192159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_iterator cbegin() const TEST_NOEXCEPT { return l_.cbegin(); } 193159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_iterator cend() const TEST_NOEXCEPT { return l_.cend(); } 194159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_reverse_iterator crbegin() const TEST_NOEXCEPT { return l_.crbegin(); } 195159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier const_reverse_iterator crend() const TEST_NOEXCEPT { return l_.crend(); } 19653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 19753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow reference front() { return l_.front(); } 19853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow const_reference front() const { return l_.front(); } 19953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow reference back() { return l_.back(); } 20053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow const_reference back() const { return l_.back(); } 20153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 202159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier size_type size() const TEST_NOEXCEPT { return l_.size(); } 203159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier size_type max_size() const TEST_NOEXCEPT { return l_.max_size(); } 204159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier bool empty() const TEST_NOEXCEPT { return l_.empty(); } 20553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 20653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void push_front(const value_type& x) { l_.push_front(x); } 20753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void push_back(const value_type& x) { l_.push_back(x); } 208869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 20953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void push_back(value_type&& x) { l_.push_back(std::forward<value_type&&>(x)); } 21053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void push_front(value_type&& x) { l_.push_back(std::forward<value_type&&>(x)); } 21153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class... Args> 21253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void emplace_back(Args&&... args) { l_.emplace_back(std::forward<Args>(args)...); } 21353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class... Args> 21453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void emplace_front(Args&&... args) { l_.emplace_front(std::forward<Args>(args)...); } 21553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 21653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void pop_front() { l_.pop_front(); } 21753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow void pop_back() { l_.pop_back(); } 21853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 219869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 22053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class... Args> iterator emplace(const_iterator pos, Args&&... args) 22153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow { return l_.emplace(pos, std::forward<Args>(args)...); } 22253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 22384acb1ec3f7d5e0f37d7176697c2fa876c413407Eric Fiselier 22453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator insert(const_iterator pos, const value_type& x) { return l_.insert(pos, x); } 225869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 22653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator insert(const_iterator pos, value_type&& x) { return l_.insert(pos, std::forward<value_type>(x)); } 22753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 22853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator insert(const_iterator pos, size_type n, const value_type& x) { return l_.insert(pos, n, x); } 22953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow template <class InputIterator> 23053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator insert(const_iterator pos, InputIterator first, InputIterator last) 23153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow { return l_.insert(pos, first, last); } 23253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 233869c5adc9021164312bd4d08cba38f328950e076Eric Fiselier#if TEST_STD_VER >= 11 23453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator insert(const_iterator pos, std::initializer_list<value_type> il) { return l_.insert(pos, il); } 23553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 23653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 23753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator erase(const_iterator pos) { return l_.erase(pos); } 23853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow iterator erase(const_iterator pos, const_iterator last) { return l_.erase(pos, last); } 23953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 2400e5ebbc77c3c2cfd7d835fcfe40fcb65df0c5598Eric Fiselier void resize(size_type) { l_.resize(); } 2410e5ebbc77c3c2cfd7d835fcfe40fcb65df0c5598Eric Fiselier void resize(size_type, const value_type& c) { l_.resize(c); } 24253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 243159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier void swap(nasty_list &nl) 244159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier#if TEST_STD_VER > 14 245159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier noexcept(std::is_nothrow_swappable<nested_container>::value) 246159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier#elif defined(_LIBCPP_VERSION) 247159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier TEST_NOEXCEPT_COND(std::__is_nothrow_swappable<nested_container>::value) 248159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier#endif 24953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow { l_.swap(nl.l_); } 25084acb1ec3f7d5e0f37d7176697c2fa876c413407Eric Fiselier 251159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier void clear() TEST_NOEXCEPT { l_.clear(); } 25253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 25353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void splice(const_iterator position, list& x); 25453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void splice(const_iterator position, list&& x); 25553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void splice(const_iterator position, list& x, const_iterator i); 25653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void splice(const_iterator position, list&& x, const_iterator i); 25753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void splice(const_iterator position, list& x, const_iterator first, 25853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// const_iterator last); 25953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void splice(const_iterator position, list&& x, const_iterator first, 26053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// const_iterator last); 26184acb1ec3f7d5e0f37d7176697c2fa876c413407Eric Fiselier// 26253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void remove(const value_type& value); 26353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// template <class Pred> void remove_if(Pred pred); 26453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void unique(); 26553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// template <class BinaryPredicate> 26653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void unique(BinaryPredicate binary_pred); 26753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void merge(list& x); 26853c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void merge(list&& x); 26953c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// template <class Compare> 27053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void merge(list& x, Compare comp); 27153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// template <class Compare> 27253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void merge(list&& x, Compare comp); 27353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void sort(); 27453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// template <class Compare> 27553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void sort(Compare comp); 27653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow// void reverse() noexcept; 27753c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 278d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow nasty_list *operator &() { assert(false); return nullptr; } // nasty 279d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow const nasty_list *operator &() const { assert(false); return nullptr; } // nasty 28053c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 28153c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow nested_container l_; 28253c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow}; 28353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 28453c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clowtemplate <class T> 28553c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clowbool operator==(const nasty_list<T>& x, const nasty_list<T>& y) { return x.l_ == y.l_; } 28653c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow 287d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow// Not really a mutex, but can play one in tests 288d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clowclass nasty_mutex 289d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow{ 290d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clowpublic: 291159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier nasty_mutex() TEST_NOEXCEPT {} 292d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow ~nasty_mutex() {} 293d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow 294a686caad209c0475fd69346fe841ebb67a6eb06eStephan T. Lavavej nasty_mutex *operator& () { assert(false); return nullptr; } 295a686caad209c0475fd69346fe841ebb67a6eb06eStephan T. Lavavej template <typename T> 296a686caad209c0475fd69346fe841ebb67a6eb06eStephan T. Lavavej void operator, (const T &) { assert(false); } 297d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow 298d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clowprivate: 299d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow nasty_mutex(const nasty_mutex&) { assert(false); } 300d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow nasty_mutex& operator=(const nasty_mutex&) { assert(false); return *this; } 301d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow 302d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clowpublic: 303d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow void lock() {} 304159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier bool try_lock() TEST_NOEXCEPT { return true; } 305159b45f505b3ddc3d25a1493af95cb5b6827a925Eric Fiselier void unlock() TEST_NOEXCEPT {} 306d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow 307d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow // Shared ownership 308d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow void lock_shared() {} 309d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow bool try_lock_shared() { return true; } 310d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow void unlock_shared() {} 311d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow}; 312d124b5b45d355fa717336c4378a88539b8b2e075Marshall Clow 31353c0e72d5c5b7ccfa2234efbd84be5d6749dea89Marshall Clow#endif 314