Skip to content

Commit 3e1382a

Browse files
committed
Fix #41: Fix the C++17 build breakage introduced in 840ac79
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.
1 parent 151679a commit 3e1382a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cppcodec/data/access.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,17 @@ CPPCODEC_ALWAYS_INLINE array_access_result_state<Result> create_state(Result&, s
263263
return array_access_result_state<Result>();
264264
}
265265

266+
#if __cplusplus < 201703L
266267
static_assert(std::is_same<
267268
decltype(create_state(*(std::string*)nullptr, specific_t())),
268269
array_access_result_state<std::string>>::value,
269-
"std::string must be handled by array_access_result_state");
270+
"std::string (pre-C++17) must be handled by array_access_result_state");
271+
#else
272+
static_assert(std::is_same<
273+
decltype(create_state(*(std::string*)nullptr, specific_t())),
274+
direct_data_access_result_state<std::string>>::value,
275+
"std::string (C++17 and later) must be handled by direct_data_access_result_state");
276+
#endif
270277

271278
// Specialized init(), put() and finish() functions for array_access_result_state.
272279
template <typename Result>

0 commit comments

Comments
 (0)