xo-object: streamline DFloat construction, like w/ DList/DInteger

This commit is contained in:
Roland Conybeare 2026-01-09 18:09:50 -05:00
commit 53affe2fd1
3 changed files with 14 additions and 6 deletions

View file

@ -6,6 +6,7 @@
#pragma once
#include <xo/alloc2/Allocator.hpp>
#include <xo/facet/obj.hpp>
#include <xo/indentlog/print/ppindentinfo.hpp>
namespace xo {
@ -16,9 +17,12 @@ namespace xo {
explicit DFloat(double x) : value_{x} {}
/** probably want default = ANumeric, once we introduce it **/
template <typename AFacet>
static obj<AFacet,DFloat> box(obj<AAllocator> mm, double x);
/** allocate boxed value @p x using memory from @p mm **/
static DFloat * make(obj<AAllocator> mm,
double x);
static DFloat * _box(obj<AAllocator> mm, double x);
double value() const noexcept { return value_; }
@ -31,6 +35,12 @@ namespace xo {
/** boxed floating-oint value **/
double value_;
};
template <typename AFacet>
obj<AFacet,DFloat>
DFloat::box(obj<AAllocator> mm, double x) {
return obj<AFacet,DFloat>(DFloat::_box(mm, x));
}
} /*nmaespace scm*/
} /*namespace xo*/