raw: Fix for single element containers

Single element containers have .data() but not .size(), we can make
these fall back to the non-container span constructor.

Change-Id: I68ff3e4dc714aa95a8f9397dc769a2d2cf0f9332
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/stdplus/raw.hpp b/src/stdplus/raw.hpp
index b56fb98..0d4675d 100644
--- a/src/stdplus/raw.hpp
+++ b/src/stdplus/raw.hpp
@@ -19,6 +19,12 @@
 using dataType = std::remove_pointer_t<decltype(
     std::data(std::declval<std::add_lvalue_reference_t<Container>>()))>;
 
+/** @brief Gets the sizetype referenced in a container
+ */
+template <typename Container>
+using sizeType =
+    decltype(std::size(std::declval<std::add_lvalue_reference_t<Container>>()));
+
 /** @brief Determines if the container holds trivially copyable data
  */
 template <typename Container>
@@ -36,7 +42,7 @@
 template <typename, typename = void>
 inline constexpr bool hasData = false;
 template <typename T>
-inline constexpr bool hasData<T, std::void_t<dataType<T>>> = true;
+inline constexpr bool hasData<T, std::void_t<dataType<T>, sizeType<T>>> = true;
 
 } // namespace detail
 
diff --git a/test/raw.cpp b/test/raw.cpp
index 79fb2ad..a5d4b00 100644
--- a/test/raw.cpp
+++ b/test/raw.cpp
@@ -231,7 +231,14 @@
 
 TEST_CASE("As Span", "[AsSpan]")
 {
-    uint64_t data = htole64(0xffff0000);
+    struct
+    {
+        uint64_t a;
+        uint64_t* data()
+        {
+            return &a;
+        }
+    } data = {htole64(0xffff0000)};
     auto s = asSpan<uint16_t>(data);
     CHECK(s.size() == 4);
     s[2] = 0xfefe;