-
Notifications
You must be signed in to change notification settings - Fork 1
/
fmpq_cc.h
32 lines (24 loc) · 814 Bytes
/
fmpq_cc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// C++ interface to fmpq_t
#pragma once
#include <flint/fmpq.h>
#include <string>
namespace mandelbrot {
using std::string;
struct Fmpq {
fmpq_t x;
Fmpq() { fmpq_init(x); }
Fmpq(const Fmpq& a) = delete;
explicit Fmpq(const fmpq_t a) { fmpq_init(x); fmpq_set(x, a); }
Fmpq(Fmpq&& a) { *x = *a.x; fmpq_init(a.x); }
~Fmpq() { fmpq_clear(x); }
// Assignment
Fmpq& operator=(const slong a) { fmpq_set_si(x, a, 1); return *this; }
Fmpq& operator=(const Fmpq& a) { fmpq_set(x, a.x); return *this; }
Fmpq& operator=(Fmpq&& a) { fmpq_swap(x, a.x); fmpq_zero(a.x); return *this; }
// Implicit converson
operator fmpq*() { return x; }
operator const fmpq*() const { return x; }
// Printing
friend std::ostream& operator<<(std::ostream& out, const Fmpq& a);
};
} // namespace mandelbrot