Pergunta

I'm trying to use vectors with GMP. But when I compile anything like this, I get "[...]\bits\vector.tcc [Error] array must be initialized with a brace-enclosed initializer". Any data structure with dynamic size works - a deque would be best but I had even more errors popping up when I tried that. How do I make this stop failing?

#include <vector>
#include <gmp.h>

int main(){
mpz_t test;
mpz_init(test);
std::vector<mpz_t> a_vector;
a_vector.push_back(test);
return 0;
}
Foi útil?

Solução

Since GMP numbers are not directly assignable (in other words, you can't do mpz_t test = 0;' ormpz_t test1l; test1 = test;`, I don't believe they can be used in standard C++ container types.

If you want to do that, you may want to use the C++ interface for GMP instead: https://gmplib.org/manual/C_002b_002b-Interface-General.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top