From: redi Date: Wed, 15 Oct 2014 13:20:12 +0000 (+0000) Subject: * include/std/complex (complex::real, complex::imag): Add const. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=931e67744c527e66776545ce3d5ed1235ec59a4f;p=thirdparty%2Fgcc.git * include/std/complex (complex::real, complex::imag): Add const. * testsuite/26_numerics/complex/value_operations/constexpr2.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216258 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9fcaaef09bc9..28767d25846c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2014-10-15 Jonathan Wakely + + * include/std/complex (complex::real, complex::imag): Add const. + * testsuite/26_numerics/complex/value_operations/constexpr2.cc: New. + 2014-10-15 Paolo Carlini * include/std/limits: Remove stray semicolon. diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index bf302c186729..6670ed719977 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -144,11 +144,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // DR 387. std::complex over-encapsulated. _GLIBCXX_ABI_TAG_CXX11 constexpr _Tp - real() { return _M_real; } + real() const { return _M_real; } _GLIBCXX_ABI_TAG_CXX11 constexpr _Tp - imag() { return _M_imag; } + imag() const { return _M_imag; } #else /// Return real part of complex number. _Tp& diff --git a/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr2.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr2.cc new file mode 100644 index 000000000000..e85e211fa726 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr2.cc @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-std=gnu++14" } + +// 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 +// . + +#include + +int main() +{ + constexpr std::complex c{}; + constexpr auto r __attribute__((unused)) = real(c); + constexpr auto i __attribute__((unused)) = imag(c); +}