From 526cd61b362b38d29ccc2ea3cef40a97d4ea2370 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Wed, 15 Jan 2020 16:35:49 -0500 Subject: [PATCH] Verify that custom iterator traits work correctly --- test/compile_fail.hpp | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/compile_fail.hpp diff --git a/test/compile_fail.hpp b/test/compile_fail.hpp new file mode 100644 index 0000000..912f885 --- /dev/null +++ b/test/compile_fail.hpp @@ -0,0 +1,49 @@ +#include + +#include + +#include + +namespace boost +{ +namespace static_string +{ + +static_assert(std::is_base_of< + detail::static_string_base_zero<0, char, std::char_traits>, + static_string<0>>::value, + "the zero size optimization shall be used for N = 0"); + +#ifdef BOOST_STATIC_STRING_USE_NULL_OPTIMIZATION +static_assert(std::is_base_of< + detail::static_string_base_null<1, char, std::char_traits>, + static_string<1>>::value, + "the null terminator optimization shall be used for N <= (std::numeric_limits::max)()"); + +static_assert(std::is_base_of< + detail::static_string_base_null<(std::numeric_limits::max)(), char, std::char_traits>, + static_string<(std::numeric_limits::max)()>>::value, + "the null terminator optimization shall be used for N <= std::numeric_limits::max()"); + +static_assert(std::is_base_of< + detail::static_string_base_zero<(std::numeric_limits::max)() + 1, char, std::char_traits>, + static_string<(std::numeric_limits::max)() + 1>>::value, + "the minimum size type optimization shall be used for N > std::numeric_limits::max()"); +#else +static_assert(std::is_base_of< + detail::static_string_base_zero<(std::numeric_limits::max)() + 1, char, std::char_traits>, + static_string<(std::numeric_limits::max)() + 1>>::value, + "the minimum size type optimization shall be used for N > 0"); +#endif + +static_assert(!detail::is_input_iterator::value, "is_input_iterator is incorrect"); +static_assert(!detail::is_input_iterator::value, "is_input_iterator is incorrect"); +static_assert(detail::is_input_iterator::value, "is_input_iterator is incorrect"); +static_assert(detail::is_input_iterator>::value, "is_input_iterator is incorrect"); + +static_assert(!detail::is_forward_iterator::value, "is_forward_iterator is incorrect"); +static_assert(!detail::is_forward_iterator::value, "is_forward_iterator is incorrect"); +static_assert(detail::is_forward_iterator::value, "is_forward_iterator is incorrect"); +static_assert(!detail::is_forward_iterator>::value, "is_forward_iterator is incorrect"); +} +} \ No newline at end of file