@@ -542,14 +542,13 @@ Feature-testing recommendations for C++</link>.
</row>
<row>
- <?dbhtml bgcolor="#C8B0B0" ?>
<entry> Emplace return type </entry>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0084r2.pdf">
P0084R2
</link>
</entry>
- <entry align="center"> No </entry>
+ <entry align="center"> 7 </entry>
<entry/>
</row>
@@ -129,7 +129,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template<typename _Tp, typename _Alloc>
template<typename... _Args>
+#if __cplusplus > 201402L
+ typename deque<_Tp, _Alloc>::reference
+#else
void
+#endif
deque<_Tp, _Alloc>::
emplace_front(_Args&&... __args)
{
@@ -142,11 +146,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
else
_M_push_front_aux(std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+ return front();
+#endif
}
template<typename _Tp, typename _Alloc>
template<typename... _Args>
+#if __cplusplus > 201402L
+ typename deque<_Tp, _Alloc>::reference
+#else
void
+#endif
deque<_Tp, _Alloc>::
emplace_back(_Args&&... __args)
{
@@ -160,6 +171,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
else
_M_push_back_aux(std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+ return back();
+#endif
}
#endif
@@ -797,10 +797,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* and references.
*/
template<typename... _Args>
- void
+#if __cplusplus > 201402L
+ reference
+#else
+ void
+#endif
emplace_front(_Args&&... __args)
- { this->_M_insert_after(cbefore_begin(),
- std::forward<_Args>(__args)...); }
+ {
+ this->_M_insert_after(cbefore_begin(),
+ std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+ return front();
+#endif
+ }
/**
* @brief Add data to the front of the %forward_list.
@@ -1056,9 +1056,18 @@ template<typename _Alloc>
#if __cplusplus >= 201103L
template<typename... _Args>
+#if __cplusplus > 201402L
+ reference
+#else
void
+#endif
emplace_back(_Args&&... __args)
- { push_back(bool(__args...)); }
+ {
+ push_back(bool(__args...));
+#if __cplusplus > 201402L
+ return back();
+#endif
+ }
template<typename... _Args>
iterator
@@ -1519,7 +1519,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ emplace_front(std::move(__x)); }
template<typename... _Args>
- void
+#if __cplusplus > 201402L
+ reference
+#else
+ void
+#endif
emplace_front(_Args&&... __args);
#endif
@@ -1552,7 +1556,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ emplace_back(std::move(__x)); }
template<typename... _Args>
- void
+#if __cplusplus > 201402L
+ reference
+#else
+ void
+#endif
emplace_back(_Args&&... __args);
#endif
@@ -1069,9 +1069,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
{ this->_M_insert(begin(), std::move(__x)); }
template<typename... _Args>
- void
+#if __cplusplus > 201402L
+ reference
+#else
+ void
+#endif
emplace_front(_Args&&... __args)
- { this->_M_insert(begin(), std::forward<_Args>(__args)...); }
+ {
+ this->_M_insert(begin(), std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+ return front();
+#endif
+ }
#endif
/**
@@ -1110,9 +1119,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
{ this->_M_insert(end(), std::move(__x)); }
template<typename... _Args>
- void
+#if __cplusplus > 201402L
+ reference
+#else
+ void
+#endif
emplace_back(_Args&&... __args)
- { this->_M_insert(end(), std::forward<_Args>(__args)...); }
+ {
+ this->_M_insert(end(), std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+ return back();
+#endif
+ }
#endif
/**
@@ -247,11 +247,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
push(value_type&& __x)
{ c.push_back(std::move(__x)); }
+#if __cplusplus > 201402L
+ template<typename... _Args>
+ decltype(auto)
+ emplace(_Args&&... __args)
+ { return c.emplace_back(std::forward<_Args>(__args)...); }
+#else
template<typename... _Args>
void
emplace(_Args&&... __args)
{ c.emplace_back(std::forward<_Args>(__args)...); }
#endif
+#endif
/**
* @brief Removes first element.
@@ -223,11 +223,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
push(value_type&& __x)
{ c.push_back(std::move(__x)); }
+#if __cplusplus > 201402L
+ template<typename... _Args>
+ decltype(auto)
+ emplace(_Args&&... __args)
+ { return c.emplace_back(std::forward<_Args>(__args)...); }
+#else
template<typename... _Args>
void
emplace(_Args&&... __args)
{ c.emplace_back(std::forward<_Args>(__args)...); }
#endif
+#endif
/**
* @brief Removes first element.
@@ -960,7 +960,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ emplace_back(std::move(__x)); }
template<typename... _Args>
+#if __cplusplus > 201402L
+ reference
+#else
void
+#endif
emplace_back(_Args&&... __args);
#endif
@@ -87,7 +87,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template<typename _Tp, typename _Alloc>
template<typename... _Args>
+#if __cplusplus > 201402L
+ typename vector<_Tp, _Alloc>::reference
+#else
void
+#endif
vector<_Tp, _Alloc>::
emplace_back(_Args&&... __args)
{
@@ -99,6 +103,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
else
_M_realloc_insert(end(), std::forward<_Args>(__args)...);
+#if __cplusplus > 201402L
+ return back();
+#endif
}
#endif
@@ -386,19 +386,33 @@ namespace __debug
{ emplace_back(std::move(__x)); }
template<typename... _Args>
+#if __cplusplus > 201402L
+ reference
+#else
void
+#endif
emplace_front(_Args&&... __args)
{
_Base::emplace_front(std::forward<_Args>(__args)...);
this->_M_invalidate_all();
+#if __cplusplus > 201402L
+ return front();
+#endif
}
template<typename... _Args>
+#if __cplusplus > 201402L
+ reference
+#else
void
+#endif
emplace_back(_Args&&... __args)
{
_Base::emplace_back(std::forward<_Args>(__args)...);
this->_M_invalidate_all();
+#if __cplusplus > 201402L
+ return back();
+#endif
}
template<typename... _Args>
@@ -478,7 +478,11 @@ namespace __debug
{ emplace_back(std::move(__x)); }
template<typename... _Args>
+#if __cplusplus > 201402L
+ deque<_Tp, _Alloc>::reference
+#else
void
+#endif
emplace_back(_Args&&... __args)
{
bool __realloc = this->_M_requires_reallocation(this->size() + 1);
@@ -486,6 +490,9 @@ namespace __debug
if (__realloc)
this->_M_invalidate_all();
this->_M_update_guaranteed_capacity();
+#if __cplusplus > 201402L
+ return back();
+#endif
}
#endif
new file mode 100644
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <deque>
+#include <testsuite_hooks.h>
+
+using test_type = std::deque<int>;
+
+void
+test01()
+{
+ test_type x{1, 2, 3, 4};
+ test_type::reference r = x.emplace_front(0);
+ VERIFY( r == 0 );
+ VERIFY( &r == &x.front() );
+}
+
+void
+test02()
+{
+ test_type x{1, 2, 3, 4};
+ test_type::reference r = x.emplace_back(5);
+ VERIFY( r == 5 );
+ VERIFY( &r == &x.back() );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+}
new file mode 100644
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+
+using test_type = std::forward_list<int>;
+
+void
+test01()
+{
+ test_type x{1, 2, 3, 4};
+ test_type::reference r = x.emplace_front(0);
+ VERIFY( r == 0 );
+ VERIFY( &r == &x.front() );
+}
+
+int
+main()
+{
+ test01();
+}
new file mode 100644
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <list>
+#include <testsuite_hooks.h>
+
+using test_type = std::list<int>;
+
+void
+test01()
+{
+ test_type x{1, 2, 3, 4};
+ test_type::reference r = x.emplace_front(0);
+ VERIFY( r == 0 );
+ VERIFY( &r == &x.front() );
+}
+
+void
+test02()
+{
+ test_type x{1, 2, 3, 4};
+ test_type::reference r = x.emplace_back(5);
+ VERIFY( r == 5 );
+ VERIFY( &r == &x.back() );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+}
new file mode 100644
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <queue>
+#include <testsuite_hooks.h>
+
+using test_type = std::queue<int>;
+
+void
+test01()
+{
+ test_type x{ test_type::container_type{1, 2, 3, 4} };
+ test_type::reference r = x.emplace(5);
+ VERIFY( r == 5 );
+ VERIFY( &r == &x.back() );
+}
+
+int
+main()
+{
+ test01();
+}
new file mode 100644
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <stack>
+#include <testsuite_hooks.h>
+
+using test_type = std::stack<int>;
+
+void
+test01()
+{
+ test_type x{ test_type::container_type{1, 2, 3, 4} };
+ test_type::reference r = x.emplace(5);
+ VERIFY( r == 5 );
+ VERIFY( &r == &x.top() );
+}
+
+int
+main()
+{
+ test01();
+}
new file mode 100644
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <vector>
+#include <testsuite_hooks.h>
+
+using test_type = std::vector<bool>;
+
+void
+test02()
+{
+ test_type x{true, true};
+ test_type::reference r = x.emplace_back(false);
+ VERIFY( r == false );
+}
+
+int
+main()
+{
+ test02();
+}
new file mode 100644
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target c++1z } }
+
+#include <vector>
+#include <testsuite_hooks.h>
+
+using test_type = std::vector<int>;
+
+void
+test02()
+{
+ test_type x{1, 2, 3, 4};
+ test_type::reference r = x.emplace_back(5);
+ VERIFY( r == 5 );
+ VERIFY( &r == &x.back() );
+}
+
+int
+main()
+{
+ test02();
+}