diff --git a/doc/pointer_in_range.qbk b/doc/pointer_in_range.qbk index 8a21df9..7da7b6d 100644 --- a/doc/pointer_in_range.qbk +++ b/doc/pointer_in_range.qbk @@ -33,7 +33,7 @@ template void Allocator::deallocate(pointer ptr, size_type) { - if (!boost::pointer_in_range(ptr, &buffer_[0], &buffer_[N])) { + if (!boost::pointer_in_range(ptr, buffer_, buffer_ + N)) { ::operator delete(ptr); } } @@ -58,6 +58,7 @@ constexpr bool pointer_in_range(const T* ptr, const T* begin, const T* end); [[`template constexpr bool pointer_in_range(const T* ptr, const T* begin, T* end);`] [[variablelist +[[Requires][`[begin,end)` is a valid range.]] [[Returns][`true` if `ptr` is in range `[begin,end)`, otherwise `false`.]]]]]] [endsect] diff --git a/include/boost/core/detail/string_view.hpp b/include/boost/core/detail/string_view.hpp index 2236545..5cce6f6 100644 --- a/include/boost/core/detail/string_view.hpp +++ b/include/boost/core/detail/string_view.hpp @@ -74,7 +74,7 @@ template BOOST_CXX14_CONSTEXPR std::size_t find_first_of( Ch const* p_ for( std::size_t j = 0; j < n; ++j ) { - UCh ch = s[ j ]; + UCh ch = static_cast( s[ j ] ); if( ch >= 0 && ch < 256 ) { @@ -91,7 +91,7 @@ template BOOST_CXX14_CONSTEXPR std::size_t find_first_of( Ch const* p_ { for( std::size_t i = pos; i < n_; ++i ) { - UCh ch = p_[ i ]; + UCh ch = static_cast( p_[ i ] ); if( ch >= 0 && ch < 256 && table[ ch ] ) return i; } } @@ -129,7 +129,7 @@ template BOOST_CXX14_CONSTEXPR std::size_t find_last_of( Ch const* p_, for( std::size_t j = 0; j < n; ++j ) { - UCh ch = s[ j ]; + UCh ch = static_cast( s[ j ] ); if( ch >= 0 && ch < 256 ) { @@ -150,7 +150,7 @@ template BOOST_CXX14_CONSTEXPR std::size_t find_last_of( Ch const* p_, { do { - UCh ch = p_[ i ]; + UCh ch = static_cast( p_[ i ] ); if( ch >= 0 && ch < 256 && table[ ch ] ) return i; @@ -199,7 +199,7 @@ template BOOST_CXX14_CONSTEXPR std::size_t find_first_not_of( Ch const for( std::size_t j = 0; j < n; ++j ) { - UCh ch = s[ j ]; + UCh ch = static_cast( s[ j ] ); if( ch >= 0 && ch < 256 ) { @@ -216,7 +216,7 @@ template BOOST_CXX14_CONSTEXPR std::size_t find_first_not_of( Ch const { for( std::size_t i = pos; i < n_; ++i ) { - UCh ch = p_[ i ]; + UCh ch = static_cast( p_[ i ] ); if( !( ch >= 0 && ch < 256 && table[ ch ] ) ) return i; } } @@ -262,7 +262,7 @@ template BOOST_CXX14_CONSTEXPR std::size_t find_last_not_of( Ch const* for( std::size_t j = 0; j < n; ++j ) { - UCh ch = s[ j ]; + UCh ch = static_cast( s[ j ] ); if( ch >= 0 && ch < 256 ) { @@ -283,7 +283,7 @@ template BOOST_CXX14_CONSTEXPR std::size_t find_last_not_of( Ch const* { do { - UCh ch = p_[ i ]; + UCh ch = static_cast( p_[ i ] ); if( !( ch >= 0 && ch < 256 && table[ ch ] ) ) return i; @@ -381,7 +381,7 @@ public: } template BOOST_CXX14_CONSTEXPR basic_string_view( Ch const* first, End last, - typename boost::enable_if >::type* = 0 ) BOOST_NOEXCEPT: p_( first ), n_( last - first ) + typename boost::enable_if >::type* = 0 ) BOOST_NOEXCEPT: p_( first ), n_( static_cast( last - first ) ) { BOOST_ASSERT( last - first >= 0 ); } @@ -681,7 +681,7 @@ public: Ch const* r = traits_type::find( data() + pos, size() - pos, c ); - return r? r - data(): npos; + return r? static_cast( r - data() ): npos; } BOOST_CXX14_CONSTEXPR size_type find( Ch const* s, size_type pos, size_type n ) const BOOST_NOEXCEPT @@ -696,11 +696,11 @@ public: for( ;; ) { - p = traits_type::find( p, last - p, s[0] ); + p = traits_type::find( p, static_cast( last - p ), s[0] ); if( p == 0 ) break; - if( traits_type::compare( p + 1, s + 1, n - 1 ) == 0 ) return p - data(); + if( traits_type::compare( p + 1, s + 1, n - 1 ) == 0 ) return static_cast( p - data() ); ++p; } @@ -1193,7 +1193,7 @@ public: template std::basic_ostream& operator<<( std::basic_ostream& os, basic_string_view str ) { Ch const* p = str.data(); - std::streamsize n = str.size(); + std::streamsize n = static_cast( str.size() ); std::streamsize m = os.width(); diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index c09ce87..43baea0 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -153,6 +153,7 @@ inline void no_throw_failed_impl(const char* expr, const char* what, const char* #elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wsign-compare" +# pragma GCC diagnostic ignored "-Wsign-conversion" #endif // specialize test output for char pointers to avoid printing as cstring diff --git a/include/boost/core/span.hpp b/include/boost/core/span.hpp index 99a2dd7..2e64262 100644 --- a/include/boost/core/span.hpp +++ b/include/boost/core/span.hpp @@ -351,8 +351,10 @@ private: detail::span_store s_; }; +#if defined(BOOST_NO_CXX17_INLINE_VARIABLES) template constexpr std::size_t span::extent; +#endif #ifdef __cpp_deduction_guides template diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 59190df..6bad911 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -25,6 +25,15 @@ local warnings-as-errors-off = "-gcc:on" "-clang:on" ; +local pedantic-errors = pedantic + gcc:"-Wconversion" + gcc:"-Wsign-conversion" + clang:"-Wconversion" + clang:"-Wsign-conversion" + msvc:on + gcc:on + clang:on ; + # quick test (for CI) run quick.cpp ; @@ -37,7 +46,8 @@ compile addressof_constexpr_test.cpp ; compile-fail addressof_fail_rvalue.cpp : $(warnings-as-errors-off) ; -run checked_delete_test.cpp ; +run checked_delete_test.cpp + : : : $(pedantic-errors) ; compile-fail checked_delete_fail.cpp : $(warnings-as-errors-off) ; compile-fail checked_delete_fail2.cpp @@ -104,13 +114,6 @@ run visit_each_test.cpp ; run get_pointer_test.cpp ; -local pedantic-errors = pedantic - gcc:"-Wconversion" - clang:"-Wconversion" - msvc:on - gcc:on - clang:on ; - run lightweight_test_test.cpp : : : $(pedantic-errors) ; run lightweight_test_test.cpp : : : @@ -337,33 +340,51 @@ run type_name_test.cpp ; run snprintf_test.cpp ; -run sv_types_test.cpp ; -run sv_construct_test.cpp ; -run sv_iteration_test.cpp ; -run sv_element_access_test.cpp ; -run sv_modifiers_test.cpp ; -run sv_copy_test.cpp ; -run sv_substr_test.cpp ; -run sv_compare_test.cpp ; -run sv_starts_with_test.cpp ; -run sv_ends_with_test.cpp ; -run sv_find_test.cpp ; -run sv_rfind_test.cpp ; +run sv_types_test.cpp + : : : $(pedantic-errors) ; +run sv_construct_test.cpp + : : : $(pedantic-errors) ; +run sv_iteration_test.cpp + : : : $(pedantic-errors) ; +run sv_element_access_test.cpp + : : : $(pedantic-errors) ; +run sv_modifiers_test.cpp + : : : $(pedantic-errors) ; +run sv_copy_test.cpp + : : : $(pedantic-errors) ; +run sv_substr_test.cpp + : : : $(pedantic-errors) ; +run sv_compare_test.cpp + : : : $(pedantic-errors) ; +run sv_starts_with_test.cpp + : : : $(pedantic-errors) ; +run sv_ends_with_test.cpp + : : : $(pedantic-errors) ; +run sv_find_test.cpp + : : : $(pedantic-errors) ; +run sv_rfind_test.cpp + : : : $(pedantic-errors) ; run sv_find_first_of_test.cpp - : : : gcc-4.4:-Wno-type-limits ; + : : : $(pedantic-errors) gcc-4.4:-Wno-type-limits ; run sv_find_last_of_test.cpp - : : : gcc-4.4:-Wno-type-limits ; + : : : $(pedantic-errors) gcc-4.4:-Wno-type-limits ; run sv_find_first_not_of_test.cpp - : : : gcc-4.4:-Wno-type-limits ; + : : : $(pedantic-errors) gcc-4.4:-Wno-type-limits ; run sv_find_last_not_of_test.cpp - : : : gcc-4.4:-Wno-type-limits ; -run sv_contains_test.cpp ; -run sv_eq_test.cpp ; -run sv_lt_test.cpp ; -run sv_stream_insert_test.cpp ; -run sv_conversion_test.cpp ; -run sv_conversion_test2.cpp /boost/utility//boost_utility : ; -run sv_common_reference_test.cpp ; + : : : $(pedantic-errors) gcc-4.4:-Wno-type-limits ; +run sv_contains_test.cpp + : : : $(pedantic-errors) ; +run sv_eq_test.cpp + : : : $(pedantic-errors) ; +run sv_lt_test.cpp + : : : $(pedantic-errors) ; +run sv_stream_insert_test.cpp + : : : $(pedantic-errors) ; +run sv_conversion_test.cpp + : : : $(pedantic-errors) ; +run sv_conversion_test2.cpp : ; +run sv_common_reference_test.cpp + : : : $(pedantic-errors) ; compile sv_common_reference_test2.cpp ; compile sv_windows_h_test.cpp ; compile-fail sv_nullptr_fail.cpp diff --git a/test/sv_find_first_not_of_test.cpp b/test/sv_find_first_not_of_test.cpp index 92b12ed..c94c5be 100644 --- a/test/sv_find_first_not_of_test.cpp +++ b/test/sv_find_first_not_of_test.cpp @@ -494,7 +494,7 @@ int main() for( int i = 0; i < 256; ++i ) { - str[ i ] = static_cast< unsigned char >( i ); + str[ i ] = static_cast( static_cast< unsigned char >( i ) ); } boost::core::string_view sv( str, 256 ); @@ -503,22 +503,22 @@ int main() std::string str2( sv.data(), sv.size() ); - for( int i = 0; i < 256; ++i ) + for( std::size_t i = 0; i < 256; ++i ) { std::string str3( str2 ); - str3[ i ] = ~str3[ i ]; + str3[ i ] = static_cast( ~str3[ i ] ); BOOST_TEST_EQ( sv.find_first_not_of( str3 ), i ); } std::reverse( str, str + 256 ); - for( int i = 0; i < 256; ++i ) + for( std::size_t i = 0; i < 256; ++i ) { std::string str3( str2 ); - str3[ i ] = ~str3[ i ]; + str3[ i ] = static_cast( ~str3[ i ] ); BOOST_TEST_EQ( sv.find_first_not_of( str3 ), 255 - i ); } @@ -538,22 +538,22 @@ int main() std::wstring str2( sv.data(), sv.size() ); - for( int i = 0; i < 256; ++i ) + for( std::size_t i = 0; i < 256; ++i ) { std::wstring str3( str2 ); - str3[ i ] = ~str3[ i ]; + str3[ i ] = static_cast( ~str3[ i ] ); BOOST_TEST_EQ( sv.find_first_not_of( str3 ), i ); } std::reverse( str, str + 256 ); - for( int i = 0; i < 256; ++i ) + for( std::size_t i = 0; i < 256; ++i ) { std::wstring str3( str2 ); - str3[ i ] = ~str3[ i ]; + str3[ i ] = static_cast( ~str3[ i ] ); BOOST_TEST_EQ( sv.find_first_not_of( str3 ), 255 - i ); } diff --git a/test/sv_find_first_of_test.cpp b/test/sv_find_first_of_test.cpp index e17ed6d..59a255f 100644 --- a/test/sv_find_first_of_test.cpp +++ b/test/sv_find_first_of_test.cpp @@ -426,14 +426,14 @@ int main() for( int i = 0; i < 256; ++i ) { - str[ i ] = static_cast< unsigned char >( i ); + str[ i ] = static_cast( static_cast< unsigned char >( i ) ); } boost::core::string_view sv( str, 256 ); for( int i = 0; i < 256; ++i ) { - std::string needle( 12, static_cast< unsigned char >( i ) ); + std::string needle( 12, static_cast( static_cast< unsigned char >( i ) ) ); BOOST_TEST_EQ( sv.find_first_of( needle ), i ); } @@ -441,7 +441,7 @@ int main() for( int i = 0; i < 256; ++i ) { - std::string needle( 12, static_cast< unsigned char >( i ) ); + std::string needle( 12, static_cast( static_cast< unsigned char >( i ) ) ); BOOST_TEST_EQ( sv.find_first_of( needle ), 255 - i ); } } diff --git a/test/sv_find_last_not_of_test.cpp b/test/sv_find_last_not_of_test.cpp index 0e7e974..6bdd017 100644 --- a/test/sv_find_last_not_of_test.cpp +++ b/test/sv_find_last_not_of_test.cpp @@ -494,7 +494,7 @@ int main() for( int i = 0; i < 256; ++i ) { - str[ i ] = static_cast< unsigned char >( i ); + str[ i ] = static_cast( static_cast< unsigned char >( i ) ); } boost::core::string_view sv( str, 256 ); @@ -503,22 +503,22 @@ int main() std::string str2( sv.data(), sv.size() ); - for( int i = 0; i < 256; ++i ) + for( std::size_t i = 0; i < 256; ++i ) { std::string str3( str2 ); - str3[ i ] = ~str3[ i ]; + str3[ i ] = static_cast( ~str3[ i ] ); BOOST_TEST_EQ( sv.find_last_not_of( str3 ), i ); } std::reverse( str, str + 256 ); - for( int i = 0; i < 256; ++i ) + for( std::size_t i = 0; i < 256; ++i ) { std::string str3( str2 ); - str3[ i ] = ~str3[ i ]; + str3[ i ] = static_cast( ~str3[ i ] ); BOOST_TEST_EQ( sv.find_last_not_of( str3 ), 255 - i ); } @@ -538,22 +538,22 @@ int main() std::wstring str2( sv.data(), sv.size() ); - for( int i = 0; i < 256; ++i ) + for( std::size_t i = 0; i < 256; ++i ) { std::wstring str3( str2 ); - str3[ i ] = ~str3[ i ]; + str3[ i ] = static_cast( ~str3[ i ] ); BOOST_TEST_EQ( sv.find_first_not_of( str3 ), i ); } std::reverse( str, str + 256 ); - for( int i = 0; i < 256; ++i ) + for( std::size_t i = 0; i < 256; ++i ) { std::wstring str3( str2 ); - str3[ i ] = ~str3[ i ]; + str3[ i ] = static_cast( ~str3[ i ] ); BOOST_TEST_EQ( sv.find_first_not_of( str3 ), 255 - i ); } diff --git a/test/sv_find_last_of_test.cpp b/test/sv_find_last_of_test.cpp index f058197..6248224 100644 --- a/test/sv_find_last_of_test.cpp +++ b/test/sv_find_last_of_test.cpp @@ -444,14 +444,14 @@ int main() for( int i = 0; i < 256; ++i ) { - str[ i ] = static_cast< unsigned char >( i ); + str[ i ] = static_cast( static_cast< unsigned char >( i ) ); } boost::core::string_view sv( str, 256 ); for( int i = 0; i < 256; ++i ) { - std::string needle( 12, static_cast< unsigned char >( i ) ); + std::string needle( 12, static_cast( static_cast< unsigned char >( i ) ) ); BOOST_TEST_EQ( sv.find_last_of( needle ), i ); } @@ -459,7 +459,7 @@ int main() for( int i = 0; i < 256; ++i ) { - std::string needle( 12, static_cast< unsigned char >( i ) ); + std::string needle( 12, static_cast( static_cast< unsigned char >( i ) ) ); BOOST_TEST_EQ( sv.find_last_of( needle ), 255 - i ); } }