| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
|
| 3 |
// Copyright (C) 2010-2025 Free Software Foundation, Inc. |
| 4 |
// |
| 5 |
// This file is part of the GNU ISO C++ Library. This library is free |
| 6 |
// software; you can redistribute it and/or modify it under the |
| 7 |
// terms of the GNU General Public License as published by the |
| 8 |
// Free Software Foundation; either version 3, or (at your option) |
| 9 |
// any later version. |
| 10 |
|
| 11 |
// This library is distributed in the hope that it will be useful, |
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
// GNU General Public License for more details. |
| 15 |
|
| 16 |
// You should have received a copy of the GNU General Public License along |
| 17 |
// with this library; see the file COPYING3. If not see |
| 18 |
// <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
#include <complex> |
| 21 |
|
| 22 |
// User defined type, so that the primary std::complex template is used. |
| 23 |
namespace numext |
| 24 |
{ |
| 25 |
struct ldld_base |
| 26 |
{ |
| 27 |
long double one; |
| 28 |
long double two; |
| 29 |
}; |
| 30 |
|
| 31 |
struct ldld_lit : public ldld_base |
| 32 |
{ }; |
| 33 |
|
| 34 |
struct ldld_nonlit : public ldld_base |
| 35 |
{ |
| 36 |
~ldld_nonlit() { } |
| 37 |
}; |
| 38 |
|
| 39 |
bool |
| 40 |
operator<(const ldld_base __a, const ldld_base __b) |
| 41 |
{ return __a.one < __b.one && __a.two < __b.two; } |
| 42 |
|
| 43 |
bool |
| 44 |
operator==(const ldld_base __a, const ldld_base __b) |
| 45 |
{ return __a.one == __b.one && __a.two == __b.two; } |
| 46 |
|
| 47 |
ldld_base |
| 48 |
operator+=(const ldld_base __a, const ldld_base __b) |
| 49 |
{ return ldld_base({ __a.one + __b.one, __a.two + __b.two}); } |
| 50 |
|
| 51 |
ldld_base |
| 52 |
operator-=(const ldld_base __a, const ldld_base __b) |
| 53 |
{ return ldld_base({ __a.one - __b.one, __a.two - __b.two}); } |
| 54 |
|
| 55 |
ldld_base |
| 56 |
operator*=(const ldld_base __a, const ldld_base __b) |
| 57 |
{ return ldld_base({ __a.one * __b.one, __a.two * __b.two}); } |
| 58 |
|
| 59 |
ldld_base |
| 60 |
operator/=(const ldld_base __a, const ldld_base __b) |
| 61 |
{ return ldld_base({ __a.one / __b.one, __a.two / __b.two}); } |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
constexpr std::complex<numext::ldld_lit> lit; // ok |
| 66 |
// constexpr std::complex<numext::ldld_nonlit> nonlit; // error |