diff options
author | Ed Smith-Rowland <3dw4rd@verizon.net> | 2013-10-23 00:09:19 +0000 |
---|---|---|
committer | Edward Smith-Rowland <emsr@gcc.gnu.org> | 2013-10-23 00:09:19 +0000 |
commit | ae5543e66213b694f07474cc98fba9d4c5b0defc (patch) | |
tree | 0b96fbfd96ca1a11dbecbcfedf40258a66d603eb /libstdc++-v3/testsuite/26_numerics | |
parent | df2ba612878f96751235dae5f926f829d4245c92 (diff) | |
download | gcc-ae5543e66213b694f07474cc98fba9d4c5b0defc.zip gcc-ae5543e66213b694f07474cc98fba9d4c5b0defc.tar.gz gcc-ae5543e66213b694f07474cc98fba9d4c5b0defc.tar.bz2 |
Implement N3779 - User-defined Literals for std::complex, part 2 of UDL for Standard Library Types
2013-09-27 Ed Smith-Rowland <3dw4rd@verizon.net>
Implement N3779 - User-defined Literals for std::complex,
part 2 of UDL for Standard Library Types
* include/std/complex: Add complex literal operators.
* testsuite/26_numerics/complex/literals/types.cc: New.
* testsuite/26_numerics/complex/literals/values.cc: New.
From-SVN: r203940
Diffstat (limited to 'libstdc++-v3/testsuite/26_numerics')
-rw-r--r-- | libstdc++-v3/testsuite/26_numerics/complex/literals/types.cc | 46 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/26_numerics/complex/literals/values.cc | 48 |
2 files changed, 94 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/26_numerics/complex/literals/types.cc b/libstdc++-v3/testsuite/26_numerics/complex/literals/types.cc new file mode 100644 index 0000000..e5f9b8c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/literals/types.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++1y" } +// { dg-do compile } + +// Copyright (C) 2013 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 <complex> +#include <type_traits> + +void +test02() +{ + using namespace std::literals::complex_literals; + + static_assert(std::is_same<decltype(1.0if), std::complex<float>>::value, + "1.0if is std::complex<float>"); + + static_assert(std::is_same<decltype(1if), std::complex<float>>::value, + "1if is std::complex<float>"); + + static_assert(std::is_same<decltype(1.0i), std::complex<double>>::value, + "1.0i is std::complex<double>"); + + static_assert(std::is_same<decltype(1i), std::complex<double>>::value, + "1i is std::complex<double>"); + + static_assert(std::is_same<decltype(1.0il), std::complex<long double>>::value, + "1.0il is std::complex<long double>"); + + static_assert(std::is_same<decltype(1il), std::complex<long double>>::value, + "1il is std::complex<long double>"); +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/literals/values.cc b/libstdc++-v3/testsuite/26_numerics/complex/literals/values.cc new file mode 100644 index 0000000..e56727e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/literals/values.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do run } + +// Copyright (C) 2013 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 <complex> +#include <testsuite_hooks.h> + +void +test02() +{ + using namespace std::literals::complex_literals; + + std::complex<float> j1 = 1.0if; + std::complex<float> k1 = 1if; + std::complex<double> j2 = 2.0i; + std::complex<double> k2 = 2i; + std::complex<long double> j4 = 4.0il; + std::complex<long double> k4 = 4il; + + VERIFY( j1 == std::complex<float>(0.0F, 1.0F) ); + VERIFY( k1 == std::complex<float>(0.0F, 1.0F) ); + VERIFY( j2 == std::complex<double>(0.0, 2.0) ); + VERIFY( k2 == std::complex<double>(0.0, 2.0) ); + VERIFY( j4 == std::complex<long double>(0.0L, 4.0L) ); + VERIFY( k4 == std::complex<long double>(0.0L, 4.0L) ); +} + +int +main() +{ + test02(); +} |