mirror of
https://github.com/darlinghq/darling-libcxx.git
synced 2024-11-27 05:40:48 +00:00
Implement LWG Issue #2187 (emplace_back and emplace for vector<bool>)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@188333 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bf6eda0b1e
commit
198a2a59ee
@ -216,8 +216,10 @@ public:
|
||||
const_reference back() const;
|
||||
|
||||
void push_back(const value_type& x);
|
||||
template <class... Args> void emplace_back(Args&&... args); // C++14
|
||||
void pop_back();
|
||||
|
||||
template <class... Args> iterator emplace(const_iterator position, Args&&... args); // C++14
|
||||
iterator insert(const_iterator position, const value_type& x);
|
||||
iterator insert(const_iterator position, size_type n, const value_type& x);
|
||||
template <class InputIterator>
|
||||
@ -2221,8 +2223,20 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);}
|
||||
|
||||
void push_back(const value_type& __x);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
|
||||
{ push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); }
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args)
|
||||
{ return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); }
|
||||
#endif
|
||||
|
||||
iterator insert(const_iterator __position, const value_type& __x);
|
||||
iterator insert(const_iterator __position, size_type __n, const value_type& __x);
|
||||
iterator insert(const_iterator __position, size_type __n, const_reference __x);
|
||||
|
68
test/containers/sequences/vector.bool/emplace.pass.cpp
Normal file
68
test/containers/sequences/vector.bool/emplace.pass.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <vector>
|
||||
// vector<bool>
|
||||
|
||||
// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
|
||||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::vector<bool> C;
|
||||
C c;
|
||||
|
||||
C::iterator i = c.emplace(c.cbegin());
|
||||
assert(i == c.begin());
|
||||
assert(c.size() == 1);
|
||||
assert(c.front() == false);
|
||||
|
||||
i = c.emplace(c.cend(), true);
|
||||
assert(i == c.end()-1);
|
||||
assert(c.size() == 2);
|
||||
assert(c.front() == false);
|
||||
assert(c.back() == true);
|
||||
|
||||
i = c.emplace(c.cbegin()+1, 1 == 1);
|
||||
assert(i == c.begin()+1);
|
||||
assert(c.size() == 3);
|
||||
assert(c.front() == false);
|
||||
assert(c[1] == true);
|
||||
assert(c.back() == true);
|
||||
}
|
||||
{
|
||||
typedef std::vector<bool, min_allocator<bool>> C;
|
||||
C c;
|
||||
|
||||
C::iterator i = c.emplace(c.cbegin());
|
||||
assert(i == c.begin());
|
||||
assert(c.size() == 1);
|
||||
assert(c.front() == false);
|
||||
|
||||
i = c.emplace(c.cend(), true);
|
||||
assert(i == c.end()-1);
|
||||
assert(c.size() == 2);
|
||||
assert(c.front() == false);
|
||||
assert(c.back() == true);
|
||||
|
||||
i = c.emplace(c.cbegin()+1, 1 == 1);
|
||||
assert(i == c.begin()+1);
|
||||
assert(c.size() == 3);
|
||||
assert(c.size() == 3);
|
||||
assert(c.front() == false);
|
||||
assert(c[1] == true);
|
||||
assert(c.back() == true);
|
||||
}
|
||||
#endif
|
||||
}
|
57
test/containers/sequences/vector.bool/emplace_back.pass.cpp
Normal file
57
test/containers/sequences/vector.bool/emplace_back.pass.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <vector>
|
||||
// vector.bool
|
||||
|
||||
// template <class... Args> void emplace_back(Args&&... args);
|
||||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::vector<bool> C;
|
||||
C c;
|
||||
c.emplace_back();
|
||||
assert(c.size() == 1);
|
||||
assert(c.front() == false);
|
||||
c.emplace_back(true);
|
||||
assert(c.size() == 2);
|
||||
assert(c.front() == false);
|
||||
assert(c.back() == true);
|
||||
c.emplace_back(1 == 1);
|
||||
assert(c.size() == 3);
|
||||
assert(c.front() == false);
|
||||
assert(c[1] == true);
|
||||
assert(c.back() == true);
|
||||
}
|
||||
{
|
||||
typedef std::vector<bool, min_allocator<bool>> C;
|
||||
C c;
|
||||
|
||||
c.emplace_back();
|
||||
assert(c.size() == 1);
|
||||
assert(c.front() == false);
|
||||
c.emplace_back(true);
|
||||
assert(c.size() == 2);
|
||||
assert(c.front() == false);
|
||||
assert(c.back() == true);
|
||||
c.emplace_back(1 == 1);
|
||||
assert(c.size() == 3);
|
||||
assert(c.front() == false);
|
||||
assert(c[1] == true);
|
||||
assert(c.back() == true);
|
||||
}
|
||||
#endif
|
||||
}
|
@ -123,7 +123,7 @@
|
||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2174">2174</a></td><td>wstring_convert::converted() should be noexcept</td><td>Bristol</td><td></td></tr>
|
||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2175">2175</a></td><td>string_convert and wbuffer_convert validity</td><td>Bristol</td><td></td></tr>
|
||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2177">2177</a></td><td>Requirements on Copy/MoveInsertable</td><td>Bristol</td><td></td></tr>
|
||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2187">2187</a></td><td>vector<bool> is missing emplace and emplace_back member functions</td><td>Bristol</td><td>Not complete</td></tr>
|
||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2187">2187</a></td><td>vector<bool> is missing emplace and emplace_back member functions</td><td>Bristol</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2197">2197</a></td><td>Specification of is_[un]signed unclear for non-arithmetic types</td><td>Bristol</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2200">2200</a></td><td>Data race avoidance for all containers, not only for sequences</td><td>Bristol</td><td></td></tr>
|
||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2209">2209</a></td><td>assign() overspecified for sequence containers</td><td>Bristol</td><td></td></tr>
|
||||
|
Loading…
Reference in New Issue
Block a user