summaryrefslogtreecommitdiff
path: root/modules/codec/c++/data.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-11-07 18:05:26 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-11-07 18:05:26 +0100
commit2e836ead5c10f00917560e9a98d46b59b2f977d4 (patch)
treeeba00a1337dbca7db3937c56d7ba9f20f9a9d146 /modules/codec/c++/data.hpp
parentbeed9c20da5fbacf8626e2d4b747bb84ae7f6d93 (diff)
downloadforstio-forstio-2e836ead5c10f00917560e9a98d46b59b2f977d4.tar.gz
Fixing double bracketing
Diffstat (limited to 'modules/codec/c++/data.hpp')
-rw-r--r--modules/codec/c++/data.hpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp
index c43402e..a8b7836 100644
--- a/modules/codec/c++/data.hpp
+++ b/modules/codec/c++/data.hpp
@@ -330,13 +330,28 @@ public:
{
}
- /*
+ /**
+ * Forwarding constructor, so the elements can be written without
+ * spelling out the inner array.
+ *
+ * data<FixedArray<UInt64,3>>{0,1,2} instead of {{0,1,2}}
+ *
+ * The guards keep it out of the way of the copy and the meta schema
+ * constructor in the single element case.
+ *
+ * Explicit for a single element, because a one dimensional index would
+ * otherwise be convertible to both data<UInt64> and this, which makes
+ * the two at overloads of data<Array<T,1>> ambiguous.
+ */
template<typename... Args>
- requires (sizeof...(Args) == ct_multiply<uint64_t, D...>::value) &&
- (std::constructible_from<data<T, encode::Native>, Args> && ...)
- constexpr data(Args&&... args):
- value_{ { std::forward<Args>(args)... } } {}
- */
+ requires (sizeof...(Args) == ct_multiply<uint64_t, D...>::value)
+ && (sizeof...(Args) > 1u
+ || (!std::same_as<std::remove_cvref_t<Args>, data> && ...))
+ && (!std::same_as<std::remove_cvref_t<Args>, data<MetaSchema, encode::Native>> && ...)
+ && (std::constructible_from<data<T, encode::Native>, Args> && ...)
+ explicit(sizeof...(Args) == 1u) constexpr data(Args&&... args):
+ value_{ data<T, encode::Native>{std::forward<Args>(args)}... }
+ {}
SAW_DEFAULT_COPY(data);
SAW_DEFAULT_MOVE(data);