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