Fix #41: Fix the C++17 build breakage introduced in 840ac79
authorJakob Petsovits <jpetso@gmx.at>
Sat, 31 Mar 2018 15:05:20 +0000 (11:05 -0400)
committerJakob Petsovits <jpetso@gmx.at>
Sat, 31 Mar 2018 15:19:05 +0000 (11:19 -0400)
In C++17, std::string::data() returns a non-const char pointer,
which means that our direct_data_access_result_state will
handle it instead of array_access_result_state.

This commit updates the static_assert() to reflect this change,
with no changes in behavior otherwise.

cppcodec/data/access.hpp

index 49727f1..02457d3 100644 (file)
@@ -263,10 +263,17 @@ CPPCODEC_ALWAYS_INLINE array_access_result_state<Result> create_state(Result&, s
     return array_access_result_state<Result>();
 }
 
+#if __cplusplus < 201703L
 static_assert(std::is_same<
         decltype(create_state(*(std::string*)nullptr, specific_t())),
         array_access_result_state<std::string>>::value,
-        "std::string must be handled by array_access_result_state");
+        "std::string (pre-C++17) must be handled by array_access_result_state");
+#else
+static_assert(std::is_same<
+        decltype(create_state(*(std::string*)nullptr, specific_t())),
+        direct_data_access_result_state<std::string>>::value,
+        "std::string (C++17 and later) must be handled by direct_data_access_result_state");
+#endif
 
 // Specialized init(), put() and finish() functions for array_access_result_state.
 template <typename Result>