brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 5660624 Raw
56 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <complex>10 11// complex& operator*=(const T& rhs); // constexpr in C++2012 13#include <complex>14#include <cassert>15 16#include "test_macros.h"17 18template <class T>19TEST_CONSTEXPR_CXX2020bool21test()22{23    std::complex<T> c(1);24    assert(c.real() == 1);25    assert(c.imag() == 0);26    c *= 1.5;27    assert(c.real() == 1.5);28    assert(c.imag() == 0);29    c *= 1.5;30    assert(c.real() == 2.25);31    assert(c.imag() == 0);32    c *= -1.5;33    assert(c.real() == -3.375);34    assert(c.imag() == 0);35    c.imag(2);36    c *= 1.5;37    assert(c.real() == -5.0625);38    assert(c.imag() == 3);39    return true;40}41 42int main(int, char**)43{44    test<float>();45    test<double>();46    test<long double>();47 48#if TEST_STD_VER >= 2049    static_assert(test<float>());50    static_assert(test<double>());51    static_assert(test<long double>());52#endif53 54  return 0;55}56