+2014-12-22 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ PR libstdc++/60271
+ C++14 constexpr min, max, minmax, min_element, max_element
+ and minmax_element. Also constexpr for 20.9.5-20.9.9,
+ aka various library functors.
+ * include/bits/c++config: Add _GLIBCXX14_CONSTEXPR.
+ * include/bits/algorithmfwd.h (min, max, minmax, min_element,
+ max_element): Use it.
+ * include/bits/predefined_ops.h (_Iter_less_iter, __iter_less_iter,
+ _Iter_comp_iter, __iter_comp_iter): Likewise.
+ * include/bits/stl_algo.h (minmax, __minmax_element, minmax_element,
+ min, max, __min_element, min_element, __max_element, max_element)
+ Likewise.
+ * include/bits/stl_algobase.h (min, max): Likewise.
+ * include/bits/stl_function.h (plus, minus, multiplies, divides,
+ modulus, negate, equal_to, not_equal_to, greater, less, greater_equal,
+ less_equal, logical_and, logical_or, logical_not, bit_and, bit_or,
+ bit_xor, bit_not, unary_negate, not1, binary_negate, not2): Likewise.
+ * testsuite/20_util/function_objects/constexpr.cc: New.
+ * testsuite/25_algorithms/max/constexpr.cc: Likewise.
+ * testsuite/25_algorithms/max_element/constexpr.cc: Likewise.
+ * testsuite/25_algorithms/min/constexpr.cc: Likewise.
+ * testsuite/25_algorithms/min_element/constexpr.cc: Likewise.
+ * testsuite/25_algorithms/minmax/constexpr.cc: Likewise.
+ * testsuite/25_algorithms/minmax_element/constexpr.cc: Likewise.
+ * testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error.
+
2014-12-22 Jonathan Wakely <jwakely@redhat.com>
* doc/xml/manual/status_cxx2011.xml: Update.
make_heap(_RAIter, _RAIter, _Compare);
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
const _Tp&
max(const _Tp&, const _Tp&);
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
const _Tp&
max(const _Tp&, const _Tp&, _Compare);
// merge
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
const _Tp&
min(const _Tp&, const _Tp&);
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
const _Tp&
min(const _Tp&, const _Tp&, _Compare);
#if __cplusplus >= 201103L
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
pair<const _Tp&, const _Tp&>
minmax(const _Tp&, const _Tp&);
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
pair<const _Tp&, const _Tp&>
minmax(const _Tp&, const _Tp&, _Compare);
template<typename _FIter>
+ _GLIBCXX14_CONSTEXPR
pair<_FIter, _FIter>
minmax_element(_FIter, _FIter);
template<typename _FIter, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
pair<_FIter, _FIter>
minmax_element(_FIter, _FIter, _Compare);
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
_Tp
min(initializer_list<_Tp>);
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
_Tp
min(initializer_list<_Tp>, _Compare);
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
_Tp
max(initializer_list<_Tp>);
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
_Tp
max(initializer_list<_Tp>, _Compare);
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
pair<_Tp, _Tp>
minmax(initializer_list<_Tp>);
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
pair<_Tp, _Tp>
minmax(initializer_list<_Tp>, _Compare);
#endif
lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);
template<typename _FIter>
+ _GLIBCXX14_CONSTEXPR
_FIter
max_element(_FIter, _FIter);
template<typename _FIter, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
_FIter
max_element(_FIter, _FIter, _Compare);
merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
template<typename _FIter>
+ _GLIBCXX14_CONSTEXPR
_FIter
min_element(_FIter, _FIter);
template<typename _FIter, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
_FIter
min_element(_FIter, _FIter, _Compare);
# endif
#endif
+#ifndef _GLIBCXX14_CONSTEXPR
+# if __cplusplus >= 201402L
+# define _GLIBCXX14_CONSTEXPR constexpr
+# else
+# define _GLIBCXX14_CONSTEXPR
+# endif
+#endif
+
// Macro for noexcept, to support in mixed 03/0x mode.
#ifndef _GLIBCXX_NOEXCEPT
# if __cplusplus >= 201103L
struct _Iter_less_iter
{
template<typename _Iterator1, typename _Iterator2>
+ _GLIBCXX14_CONSTEXPR
bool
operator()(_Iterator1 __it1, _Iterator2 __it2) const
{ return *__it1 < *__it2; }
};
-
+ _GLIBCXX14_CONSTEXPR
inline _Iter_less_iter
__iter_less_iter()
{ return _Iter_less_iter(); }
struct _Iter_comp_iter
{
_Compare _M_comp;
-
+ _GLIBCXX14_CONSTEXPR
_Iter_comp_iter(_Compare __comp)
: _M_comp(__comp)
{ }
template<typename _Iterator1, typename _Iterator2>
+ _GLIBCXX14_CONSTEXPR
bool
operator()(_Iterator1 __it1, _Iterator2 __it2)
{ return bool(_M_comp(*__it1, *__it2)); }
};
template<typename _Compare>
+ _GLIBCXX14_CONSTEXPR
inline _Iter_comp_iter<_Compare>
__iter_comp_iter(_Compare __comp)
{ return _Iter_comp_iter<_Compare>(__comp); }
* __b) otherwise.
*/
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
inline pair<const _Tp&, const _Tp&>
minmax(const _Tp& __a, const _Tp& __b)
{
* __b) otherwise.
*/
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
inline pair<const _Tp&, const _Tp&>
minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
}
template<typename _ForwardIterator, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
pair<_ForwardIterator, _ForwardIterator>
__minmax_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
|| ++__next == __last)
return std::make_pair(__first, __first);
- _ForwardIterator __min, __max;
+ _ForwardIterator __min{}, __max{};
if (__comp(__next, __first))
{
__min = __next;
* such that no other element in the range is larger.
*/
template<typename _ForwardIterator>
+ _GLIBCXX14_CONSTEXPR
inline pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last)
{
* such that no other element in the range is larger.
*/
template<typename _ForwardIterator, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
inline pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
// N2722 + DR 915.
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
inline _Tp
min(initializer_list<_Tp> __l)
{ return *std::min_element(__l.begin(), __l.end()); }
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
inline _Tp
min(initializer_list<_Tp> __l, _Compare __comp)
{ return *std::min_element(__l.begin(), __l.end(), __comp); }
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
inline _Tp
max(initializer_list<_Tp> __l)
{ return *std::max_element(__l.begin(), __l.end()); }
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
inline _Tp
max(initializer_list<_Tp> __l, _Compare __comp)
{ return *std::max_element(__l.begin(), __l.end(), __comp); }
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
inline pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __l)
{
}
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
inline pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __l, _Compare __comp)
{
}
template<typename _ForwardIterator, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
_ForwardIterator
__min_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
* @return Iterator referencing the first instance of the smallest value.
*/
template<typename _ForwardIterator>
+ _GLIBCXX14_CONSTEXPR
_ForwardIterator
inline min_element(_ForwardIterator __first, _ForwardIterator __last)
{
* according to __comp.
*/
template<typename _ForwardIterator, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
inline _ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
}
template<typename _ForwardIterator, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
_ForwardIterator
__max_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
* @return Iterator referencing the first instance of the largest value.
*/
template<typename _ForwardIterator>
+ _GLIBCXX14_CONSTEXPR
inline _ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last)
{
* according to __comp.
*/
template<typename _ForwardIterator, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
inline _ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last,
_Compare __comp)
* preprocessor macro.
*/
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
inline const _Tp&
min(const _Tp& __a, const _Tp& __b)
{
* preprocessor macro.
*/
template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
inline const _Tp&
max(const _Tp& __a, const _Tp& __b)
{
* once, unlike a preprocessor macro.
*/
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
inline const _Tp&
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
* once, unlike a preprocessor macro.
*/
template<typename _Tp, typename _Compare>
+ _GLIBCXX14_CONSTEXPR
inline const _Tp&
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
template<typename _Tp>
struct plus : public binary_function<_Tp, _Tp, _Tp>
{
+ _GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x + __y; }
template<typename _Tp>
struct minus : public binary_function<_Tp, _Tp, _Tp>
{
+ _GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x - __y; }
template<typename _Tp>
struct multiplies : public binary_function<_Tp, _Tp, _Tp>
{
+ _GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x * __y; }
template<typename _Tp>
struct divides : public binary_function<_Tp, _Tp, _Tp>
{
+ _GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x / __y; }
template<typename _Tp>
struct modulus : public binary_function<_Tp, _Tp, _Tp>
{
+ _GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x % __y; }
template<typename _Tp>
struct negate : public unary_function<_Tp, _Tp>
{
+ _GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x) const
{ return -__x; }
struct plus<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) + std::forward<_Up>(__u)))
struct minus<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) - std::forward<_Up>(__u)))
struct multiplies<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) * std::forward<_Up>(__u)))
struct divides<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) / std::forward<_Up>(__u)))
struct modulus<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) % std::forward<_Up>(__u)))
struct negate<void>
{
template <typename _Tp>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t) const
noexcept(noexcept(-std::forward<_Tp>(__t)))
template<typename _Tp>
struct equal_to : public binary_function<_Tp, _Tp, bool>
{
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x == __y; }
template<typename _Tp>
struct not_equal_to : public binary_function<_Tp, _Tp, bool>
{
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x != __y; }
template<typename _Tp>
struct greater : public binary_function<_Tp, _Tp, bool>
{
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x > __y; }
template<typename _Tp>
struct less : public binary_function<_Tp, _Tp, bool>
{
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x < __y; }
template<typename _Tp>
struct greater_equal : public binary_function<_Tp, _Tp, bool>
{
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x >= __y; }
template<typename _Tp>
struct less_equal : public binary_function<_Tp, _Tp, bool>
{
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x <= __y; }
struct equal_to<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))
struct not_equal_to<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u)))
struct greater<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u)))
struct less<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))
struct greater_equal<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)))
struct less_equal<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)))
template<typename _Tp>
struct logical_and : public binary_function<_Tp, _Tp, bool>
{
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x && __y; }
template<typename _Tp>
struct logical_or : public binary_function<_Tp, _Tp, bool>
{
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x || __y; }
template<typename _Tp>
struct logical_not : public unary_function<_Tp, bool>
{
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x) const
{ return !__x; }
struct logical_and<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u)))
struct logical_or<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u)))
struct logical_not<void>
{
template <typename _Tp>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t) const
noexcept(noexcept(!std::forward<_Tp>(__t)))
template<typename _Tp>
struct bit_and : public binary_function<_Tp, _Tp, _Tp>
{
+ _GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x & __y; }
template<typename _Tp>
struct bit_or : public binary_function<_Tp, _Tp, _Tp>
{
+ _GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x | __y; }
template<typename _Tp>
struct bit_xor : public binary_function<_Tp, _Tp, _Tp>
{
+ _GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x ^ __y; }
template<typename _Tp>
struct bit_not : public unary_function<_Tp, _Tp>
{
+ _GLIBCXX14_CONSTEXPR
_Tp
operator()(const _Tp& __x) const
{ return ~__x; }
struct bit_and<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u)))
struct bit_or<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) | std::forward<_Up>(__u)))
struct bit_xor<void>
{
template <typename _Tp, typename _Up>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t, _Up&& __u) const
noexcept(noexcept(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u)))
struct bit_not<void>
{
template <typename _Tp>
+ _GLIBCXX14_CONSTEXPR
auto
operator()(_Tp&& __t) const
noexcept(noexcept(~std::forward<_Tp>(__t)))
_Predicate _M_pred;
public:
+ _GLIBCXX14_CONSTEXPR
explicit
unary_negate(const _Predicate& __x) : _M_pred(__x) { }
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const typename _Predicate::argument_type& __x) const
{ return !_M_pred(__x); }
/// One of the @link negators negation functors@endlink.
template<typename _Predicate>
+ _GLIBCXX14_CONSTEXPR
inline unary_negate<_Predicate>
not1(const _Predicate& __pred)
{ return unary_negate<_Predicate>(__pred); }
_Predicate _M_pred;
public:
+ _GLIBCXX14_CONSTEXPR
explicit
binary_negate(const _Predicate& __x) : _M_pred(__x) { }
+ _GLIBCXX14_CONSTEXPR
bool
operator()(const typename _Predicate::first_argument_type& __x,
const typename _Predicate::second_argument_type& __y) const
/// One of the @link negators negation functors@endlink.
template<typename _Predicate>
+ _GLIBCXX14_CONSTEXPR
inline binary_negate<_Predicate>
not2(const _Predicate& __pred)
{ return binary_negate<_Predicate>(__pred); }
--- /dev/null
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 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/>.
+
+// 20.9.5-20.9.9
+
+#include <functional>
+
+static_assert(std::plus<int>()(1,2)==3, "");
+static_assert(std::minus<int>()(3,2)==1, "");
+static_assert(std::multiplies<int>()(3,2)==6, "");
+static_assert(std::divides<int>()(6,2)==3, "");
+static_assert(std::modulus<int>()(7,2)==1, "");
+static_assert(std::negate<int>()(-5)==5, "");
+
+static_assert(std::plus<void>()(1,2)==3, "");
+static_assert(std::minus<void>()(3,2)==1, "");
+static_assert(std::multiplies<void>()(3,2)==6, "");
+static_assert(std::divides<void>()(6,2)==3, "");
+static_assert(std::modulus<void>()(7,2)==1, "");
+static_assert(std::negate<void>()(-5)==5, "");
+
+static_assert(std::equal_to<int>()(2,2), "");
+static_assert(std::not_equal_to<int>()(1,2), "");
+static_assert(std::greater<int>()(2,1), "");
+static_assert(std::less<int>()(1,2), "");
+static_assert(std::greater_equal<int>()(2,2), "");
+static_assert(std::less_equal<int>()(2,2), "");
+
+static_assert(std::equal_to<void>()(2,2), "");
+static_assert(std::not_equal_to<void>()(1,2), "");
+static_assert(std::greater<void>()(2,1), "");
+static_assert(std::less<void>()(1,2), "");
+static_assert(std::greater_equal<void>()(2,2), "");
+static_assert(std::less_equal<void>()(2,2), "");
+
+static_assert(std::logical_and<int>()(1,1), "");
+static_assert(std::logical_or<int>()(0,1), "");
+static_assert(std::logical_not<int>()(0), "");
+
+static_assert(std::logical_and<void>()(1,1), "");
+static_assert(std::logical_or<void>()(0,1), "");
+static_assert(std::logical_not<void>()(0), "");
+
+static_assert(std::bit_and<int>()(3,2)==2, "");
+static_assert(std::bit_or<int>()(1,2)==3, "");
+static_assert(std::bit_xor<int>()(1,1)==0, "");
+static_assert(std::bit_not<int>()(std::bit_not<int>()(0))==0, "");
+
+static_assert(std::bit_and<void>()(3,2)==2, "");
+static_assert(std::bit_or<void>()(1,2)==3, "");
+static_assert(std::bit_xor<void>()(1,1)==0, "");
+static_assert(std::bit_not<void>()(std::bit_not<void>()(0))==0, "");
+
+static_assert(std::unary_negate<std::logical_not<int>>
+ (std::logical_not<int>())(1), "");
+static_assert(std::not1(std::logical_not<int>())(1), "");
+
+static_assert(std::binary_negate<std::logical_and<int>>
+ (std::logical_and<int>())(0,0), "");
+static_assert(std::not2(std::logical_and<int>())(0,0), "");
--- /dev/null
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 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/>.
+
+#include <algorithm>
+#include <functional>
+
+static_assert(std::max(1, 2) == 2, "");
+static_assert(std::max(2, 1, std::greater<int>()) == 1, "");
+static_assert(std::max({1, 2}) == 2, "");
+static_assert(std::max({2, 1}, std::greater<int>())==1, "");
+
--- /dev/null
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 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/>.
+
+#include <algorithm>
+#include <functional>
+#include <utility>
+
+constexpr std::initializer_list<int> test{1, 2};
+
+static_assert(*std::max_element(test.begin(), test.end()) == 2, "");
+static_assert(*std::max_element(test.begin(), test.end(),
+ std::greater<int>()) == 1, "");
--- /dev/null
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 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/>.
+
+#include <algorithm>
+#include <functional>
+
+static_assert(std::min(2, 1) == 1, "");
+static_assert(std::min(2, 1, std::greater<int>()) == 2, "");
+static_assert(std::min({2, 1}) == 1, "");
+static_assert(std::min({1, 2}, std::greater<int>())==2, "");
+
--- /dev/null
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 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/>.
+
+#include <algorithm>
+#include <functional>
+#include <utility>
+
+constexpr std::initializer_list<int> test{2, 1};
+
+static_assert(*std::min_element(test.begin(), test.end()) == 1, "");
+static_assert(*std::min_element(test.begin(), test.end(),
+ std::greater<int>()) == 2, "");
--- /dev/null
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 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/>.
+
+#include <algorithm>
+#include <functional>
+#include <utility>
+
+static_assert(std::minmax(2, 1) ==
+ std::pair<const int&, const int&>(1, 2), "");
+static_assert(std::minmax(2, 1, std::greater<int>()) ==
+ std::pair<const int&, const int&>(2, 1), "");
+static_assert(std::minmax({2, 1}) ==
+ std::pair<int, int>(1, 2), "");
+static_assert(std::minmax({2, 1}, std::greater<int>())==
+ std::pair<int, int>(2, 1), "");
--- /dev/null
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 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/>.
+
+#include <algorithm>
+#include <functional>
+#include <utility>
+
+constexpr std::initializer_list<int> test{2, 1};
+constexpr auto x = std::minmax_element(test.begin(), test.end());
+constexpr auto y = std::minmax_element(test.begin(), test.end(),
+ std::greater<int>());
+static_assert(x.first == test.begin()+1, "");
+static_assert(x.second == test.begin(), "");
+static_assert(y.first == test.begin(), "");
+static_assert(y.second == test.begin()+1, "");
+
#include <vector>
-// { dg-error "multiple inlined namespaces" "" { target *-*-* } 310 }
+// { dg-error "multiple inlined namespaces" "" { target *-*-* } 318 }