From 6684c4438611d08f60b540509e4bd05ae1efbcb8 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Mon, 8 Nov 2010 16:18:10 +0000 Subject: [PATCH] complex (operator==, !=): Mark constexpr. 2010-11-08 Benjamin Kosnik * include/std/complex (operator==, !=): Mark constexpr. * testsuite/26_numerics/complex/comparison_operators/constexpr.cc: New. From-SVN: r166439 --- libstdc++-v3/ChangeLog | 5 +++ libstdc++-v3/include/std/complex | 12 +++--- .../complex/comparison_operators/constexpr.cc | 39 +++++++++++++++++++ 3 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index fa9f25e03c8..4a5d6305f44 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2010-11-08 Benjamin Kosnik + + * include/std/complex (operator==, !=): Mark constexpr. + * testsuite/26_numerics/complex/comparison_operators/constexpr.cc: New. + 2010-11-08 Paolo Carlini * include/bits/stl_tree.h (_Rb_tree<>::_M_erase_aux): Add. diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 46a198c7e92..ffdadc3757e 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -447,17 +447,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) //@{ /// Return true if @a x is equal to @a y. template - inline bool + inline _GLIBCXX_CONSTEXPR bool operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __x.real() == __y.real() && __x.imag() == __y.imag(); } template - inline bool + inline _GLIBCXX_CONSTEXPR bool operator==(const complex<_Tp>& __x, const _Tp& __y) { return __x.real() == __y && __x.imag() == _Tp(); } template - inline bool + inline _GLIBCXX_CONSTEXPR bool operator==(const _Tp& __x, const complex<_Tp>& __y) { return __x == __y.real() && _Tp() == __y.imag(); } //@} @@ -465,17 +465,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) //@{ /// Return false if @a x is equal to @a y. template - inline bool + inline _GLIBCXX_CONSTEXPR bool operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __x.real() != __y.real() || __x.imag() != __y.imag(); } template - inline bool + inline _GLIBCXX_CONSTEXPR bool operator!=(const complex<_Tp>& __x, const _Tp& __y) { return __x.real() != __y || __x.imag() != _Tp(); } template - inline bool + inline _GLIBCXX_CONSTEXPR bool operator!=(const _Tp& __x, const complex<_Tp>& __y) { return __x != __y.real() || _Tp() != __y.imag(); } //@} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc b/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc new file mode 100644 index 00000000000..85c3ab7b4aa --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_comparison_eq_ne test; + test.operator()>(); + test.operator(), float>(); + test.operator()>(); + + test.operator()>(); + test.operator(), double>(); + test.operator()>(); + + test.operator()>(); + test.operator(), long double>(); + test.operator()>(); + return 0; +}