Change the return type of emplace_[front|back] back to void when building with C++14 or before. Resolves PR31680.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292990 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2017-01-24 23:09:12 +00:00
parent b4d17ade89
commit 4e42dc97f3
16 changed files with 256 additions and 22 deletions

View File

@@ -12,22 +12,31 @@
// <stack>
// template <class... Args> reference emplace(Args&&... args);
// return type is 'reference' in C++17; 'void' before
#include <stack>
#include <cassert>
#include "test_macros.h"
#include "../../../Emplaceable.h"
int main()
{
typedef Emplaceable T;
std::stack<Emplaceable> q;
#if TEST_STD_VER > 14
T& r1 = q.emplace(1, 2.5);
assert(&r1 == &q.top());
T& r2 = q.emplace(2, 3.5);
assert(&r2 == &q.top());
T& r3 = q.emplace(3, 4.5);
assert(&r3 == &q.top());
#else
q.emplace(1, 2.5);
q.emplace(2, 3.5);
q.emplace(3, 4.5);
#endif
assert(q.size() == 3);
assert(q.top() == Emplaceable(3, 4.5));
}