diff options
Diffstat (limited to 'sources/shiboken6/tests/libsample/stdcomplex.cpp')
-rw-r--r-- | sources/shiboken6/tests/libsample/stdcomplex.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/libsample/stdcomplex.cpp b/sources/shiboken6/tests/libsample/stdcomplex.cpp new file mode 100644 index 000000000..847174387 --- /dev/null +++ b/sources/shiboken6/tests/libsample/stdcomplex.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include "stdcomplex.h" + +#include <iostream> + +StdComplex::StdComplex() noexcept = default; + +StdComplex::StdComplex(double re, double img) noexcept : m_impl(re, img) +{ +} + +StdComplex::operator int() const +{ + return std::lround(abs_value()); +} + +StdComplex::StdComplex(const Impl &impl) noexcept : m_impl(impl) +{ +} + +StdComplex StdComplex::pow(const StdComplex &exp) const +{ + return StdComplex(std::pow(m_impl, exp.m_impl)); +} + +std::ostream &operator<<(std::ostream &str, const StdComplex &c) +{ + str << "Complex(" << c.real() << ", " << c.imag() << ')'; + return str; +} |