forked from girving/mandelbrot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacb_cc.h
33 lines (25 loc) · 802 Bytes
/
acb_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
33
// C++ interface to acb_t
#pragma once
#include <acb.h>
#include <string>
namespace mandelbrot {
using std::string;
struct Acb {
acb_t x;
Acb() { acb_init(x); }
Acb(const Acb& a) = delete;
explicit Acb(const acb_t a) { acb_init(x); acb_set(x, a); }
Acb(Acb&& a) { *x = *a.x; acb_init(a.x); }
~Acb() { acb_clear(x); }
// Assignment
Acb& operator=(const slong a) { acb_set_si(x, a); return *this; }
Acb& operator=(const Acb& a) { acb_set(x, a.x); return *this; }
Acb& operator=(Acb&& a) { acb_swap(x, a.x); acb_zero(a.x); return *this; }
// Implicit converson
operator acb_ptr() { return x; }
operator acb_srcptr() const { return x; }
// Printing
friend std::ostream& operator<<(std::ostream& out, const Acb& a);
string safe() const;
};
} // namespace mandelbrot