aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.ucl/real.ccm
blob: e0ecbb5842701f8fe51c9929e651704de2169bdb (plain) (blame)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * This source code is released into the public domain.
 */

module;

#include <compare>

#include <ucl.h>

export module nihil.ucl:real;

import :object;

namespace nihil::ucl {

export struct real final : object {
	using contained_type = double;

	inline static constexpr object_type ucl_type = object_type::real;

	// Create a new real from a UCL object.
	real(ref_t, ::ucl_object_t const *uobj);
	real(noref_t, ::ucl_object_t *uobj);

	// Create a default-initialised real.
	real();

	// Create a new real from a value.
	explicit real(contained_type value);

	// Return the value of this real.
	auto value(this real const &self) -> contained_type;
};

/*
 * Comparison operators.
 */

export auto operator== (real const &a, real const &b) -> bool;
export auto operator== (real const &a, real::contained_type b) -> bool;

export auto operator<=> (real const &a, real const &b)
	-> std::partial_ordering;
export auto operator<=> (real const &a, real::contained_type b)
	-> std::partial_ordering;

} // namespace nihil::ucl