diff options
Diffstat (limited to 'modules/codec/c++/data.hpp')
| -rw-r--r-- | modules/codec/c++/data.hpp | 27 |
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); |
