diff options
Diffstat (limited to 'nihil.ucl/real.ccm')
| -rw-r--r-- | nihil.ucl/real.ccm | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/nihil.ucl/real.ccm b/nihil.ucl/real.ccm index 4639109..d968667 100644 --- a/nihil.ucl/real.ccm +++ b/nihil.ucl/real.ccm @@ -21,16 +21,27 @@ export struct real final : object { inline static constexpr object_type ucl_type = object_type::real; - real(value_type value) - : object(::ucl_object_fromdouble(value)) + // Create a new real from a UCL object. + real(ref_t, ::ucl_object_t const *uobj) + : object(nihil::ucl::ref, uobj) { - if (_object == nullptr) - throw error("failed to create UCL object"); + if (type() != ucl_type) + throw type_mismatch(ucl_type, type()); } - explicit real(::ucl_object_t *uobj) : object(uobj) + real(noref_t, ::ucl_object_t *uobj) + : object(noref, uobj) { - assert(type() == object_type::real); + if (type() != ucl_type) + throw type_mismatch(ucl_type, type()); + } + + // Create a new real from a value. + real(value_type value) + : object(noref, ::ucl_object_fromdouble(value)) + { + if (_object == nullptr) + throw error("failed to create UCL object"); } auto value(this real const &self) -> value_type |
