-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
persistent_set.hpp
83 lines (65 loc) · 2.28 KB
/
persistent_set.hpp
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#include <jank/runtime/object.hpp>
#include <jank/runtime/obj/persistent_set_sequence.hpp>
namespace jank::runtime
{
namespace obj
{
using transient_set = static_object<object_type::transient_set>;
using transient_set_ptr = native_box<transient_set>;
}
template <>
struct static_object<object_type::persistent_set> : gc
{
using value_type = runtime::detail::native_persistent_set;
static constexpr native_bool pointer_free{ false };
static_object() = default;
static_object(static_object &&) = default;
static_object(static_object const &) = default;
static_object(native_box<static_object> meta);
static_object(value_type &&d);
static_object(value_type const &d);
static_object(runtime::detail::native_transient_set &&d);
static_object(object_ptr meta, runtime::detail::native_transient_set &&d);
template <typename... Args>
static_object(std::in_place_t, Args &&...args)
: data{ std::forward<Args>(args)... }
{
}
template <typename... Args>
static_object(object_ptr const meta, std::in_place_t, Args &&...args)
: data{ std::forward<Args>(args)... }
, meta{ meta }
{
}
static native_box<static_object> empty()
{
static auto const ret(make_box<static_object>());
return ret;
}
/* behavior::objectable */
native_bool equal(object const &) const;
native_persistent_string to_string() const;
void to_string(fmt::memory_buffer &buff) const;
native_hash to_hash() const;
/* behavior::metadatable */
object_ptr with_meta(object_ptr m) const;
/* behavior::seqable */
obj::persistent_set_sequence_ptr seq() const;
obj::persistent_set_sequence_ptr fresh_seq() const;
/* behavior::countable */
size_t count() const;
/* behavior::consable */
native_box<static_object> cons(object_ptr head) const;
/* behavior::callable */
object_ptr call(object_ptr) const;
/* behavior::transientable */
obj::transient_set_ptr to_transient() const;
native_bool contains(object_ptr o) const;
object base{ object_type::persistent_set };
value_type data;
option<object_ptr> meta;
};
using persistent_set = static_object<object_type::persistent_set>;
using persistent_set_ptr = native_box<persistent_set>;
}