私はGCCでquadmathライブラリを使用しようとしています。私は対応する四倍精度複素数、__complex128
に型キャストしたいと思います。私は交換してみた場合std :: complexをタイプキャストする<double> to __complex128
test.cpp:10:6: error: cannot convert 'std::complex<double>' to '__complex128 {aka __complex__ __float128}' in assignment
y = x;
:私は
g++ test.cpp -lquadmath -o test
でこのコードをコンパイルしようとすると、私は次のエラーを取得する
#include <quadmath.h>
#include <complex>
#include <stdio.h>
using namespace std::complex_literals;
int main(){
std::complex<double> x = 1 + 2i;
std::printf("x = %5.5g + %5.5g\n", x.real(), x.imag());
__complex128 y = 2+2i;
y = x;
return 0;
}
:以下は、最小限の(非)-working例です明示的な型キャストの割り当て行、
y = (__complex128) x;
私は
test.cpp:10:21: error: invalid cast from type 'std::complex<double>' to type '__complex128 {aka __complex__ __float128}'
y = (__complex128) x;
どのように1は、これらの2つのタイプの間の変換ず、同様のエラーを取得しますか?
ありがとうございました!それがトリックでした。私は__real__と__imag__拡張については知らなかった。ニフティ。 – Jeff