# AreAllBytesRecursiveTiedFields ```cpp= template <size_t I> struct DecayDownT : public DecayDownT<I - 1> {}; template <> struct DecayDownT<0> {}; // - /// Warning, AreAllBytesRecursiveTiedFields should not be used to indicate /// the safety of a memcpy. /// If you trust both the source and destination, you should use /// std::is_trivially_copyable. template <class T> constexpr bool AreAllBytesRecursiveTiedFields(const T& t); // - namespace AreAllBytesRecursiveTiedFieldsImpl { template <class T, std::enable_if_t<std::is_scalar<T>::value, bool> = true> constexpr bool Impl(const T&, DecayDownT<3>) { return true; } template <class T, size_t N> constexpr bool Impl(const T (&t)[N], DecayDownT<3>) { return AreAllBytesRecursiveTiedFields(t[0]); } template <class T, size_t N> constexpr bool Impl(const std::array<T, N>& t, DecayDownT<3>) { return AreAllBytesRecursiveTiedFields(t[0]); } template <class T> constexpr bool Impl(const Padding<T>& t, DecayDownT<3>) { return AreAllBytesRecursiveTiedFields(t.ignored); } // - template <class T> constexpr bool Impl(const T& t, DecayDownT<1>) { const auto tup = TiedFields(t); bool ok = AreAllBytesTiedFields(t); MapTuple(tup, [&](const auto& field) { ok &= AreAllBytesRecursiveTiedFields(field); return true; }); return ok; } } // namespace IsDenseNestedScalarsDetails // - template <class T> constexpr bool AreAllBytesRecursiveTiedFields(const T& t) { return AreAllBytesRecursiveTiedFieldsImpl::Impl(t, DecayDownT<5>{}); } static_assert(AreAllBytesRecursiveTiedFields(1)); // Compile error: Missing TiedFields: // static_assert(AreAllBytesRecursiveTiedFields(std::pair<int,int>{})); ```