diff --git a/.travis.yml b/.travis.yml index ab048db..1e0f8fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -192,6 +192,9 @@ install: - git submodule update --init libs/static_assert - git submodule update --init libs/throw_exception - git submodule update --init libs/type_traits + - git submodule update --init libs/container_hash + - git submodule update --init libs/integer + - git submodule update --init libs/detail - cp -r $TRAVIS_BUILD_DIR/* libs/utility - ./bootstrap.sh - ./b2 headers diff --git a/appveyor.yml b/appveyor.yml index 77623f0..b63ff9f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,6 +36,9 @@ install: - git submodule update --init libs/static_assert - git submodule update --init libs/throw_exception - git submodule update --init libs/type_traits + - git submodule update --init libs/container_hash + - git submodule update --init libs/integer + - git submodule update --init libs/detail - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\utility - cmd /c bootstrap - b2 -d0 headers diff --git a/call_traits.htm b/call_traits.htm index a69c1de..b4fe3ee 100644 --- a/call_traits.htm +++ b/call_traits.htm @@ -493,7 +493,7 @@ call_traits can not be used with reference or array types.

Example 1:

The following class is a trivial class that stores some type T -by value (see the call_traits_test.cpp +by value (see the call_traits_test.cpp file), the aim is to illustrate how each of the available call_traits typedefs may be used:

diff --git a/doc/base_from_member.qbk b/doc/base_from_member.qbk index 9afd949..9801214 100644 --- a/doc/base_from_member.qbk +++ b/doc/base_from_member.qbk @@ -356,7 +356,7 @@ templates that can be controlled and automated with macros. The implementation uses the [@../../../preprocessor/index.html Preprocessor library]. * [@http://www.boost.org/people/daryle_walker.html">Daryle Walker] started the -library. Contributed the test file [@../../base_from_member_test.cpp +library. Contributed the test file [@../../test/base_from_member_test.cpp base_from_member_test.cpp]. [endsect] diff --git a/include/boost/detail/compressed_pair.hpp b/include/boost/detail/compressed_pair.hpp index 5dc21e2..b090a72 100644 --- a/include/boost/detail/compressed_pair.hpp +++ b/include/boost/detail/compressed_pair.hpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -42,6 +43,14 @@ class compressed_pair; namespace details { + template::value> + struct compressed_pair_empty + : ::boost::false_type { }; + + template + struct compressed_pair_empty + : ::boost::is_empty { }; + // JM altered 26 Jan 2000: template struct compressed_pair_switch; @@ -343,8 +352,8 @@ class compressed_pair T1, T2, ::boost::is_same::type, typename remove_cv::type>::value, - ::boost::is_empty::value, - ::boost::is_empty::value>::value> + ::boost::details::compressed_pair_empty::value, + ::boost::details::compressed_pair_empty::value>::value> { private: typedef details::compressed_pair_imp::type, typename remove_cv::type>::value, - ::boost::is_empty::value, - ::boost::is_empty::value>::value> base; + ::boost::details::compressed_pair_empty::value, + ::boost::details::compressed_pair_empty::value>::value> base; public: typedef T1 first_type; typedef T2 second_type; @@ -388,8 +397,8 @@ class compressed_pair T, T, ::boost::is_same::type, typename remove_cv::type>::value, - ::boost::is_empty::value, - ::boost::is_empty::value>::value> + ::boost::details::compressed_pair_empty::value, + ::boost::details::compressed_pair_empty::value>::value> { private: typedef details::compressed_pair_imp::type, typename remove_cv::type>::value, - ::boost::is_empty::value, - ::boost::is_empty::value>::value> base; + ::boost::details::compressed_pair_empty::value, + ::boost::details::compressed_pair_empty::value>::value> base; public: typedef T first_type; typedef T second_type; diff --git a/include/boost/utility/string_ref.hpp b/include/boost/utility/string_ref.hpp index d234e54..4b36ffc 100644 --- a/include/boost/utility/string_ref.hpp +++ b/include/boost/utility/string_ref.hpp @@ -181,6 +181,7 @@ namespace boost { } size_type find(basic_string_ref s) const { + if (s.empty()) return 0; const_iterator iter = std::search ( this->cbegin (), this->cend (), s.cbegin (), s.cend (), traits::eq ); return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter ); @@ -193,6 +194,7 @@ namespace boost { } size_type rfind(basic_string_ref s) const { + if (s.empty()) return 0; const_reverse_iterator iter = std::search ( this->crbegin (), this->crend (), s.crbegin (), s.crend (), traits::eq ); return iter == this->crend () ? npos : (std::distance(iter, this->crend()) - s.size()); diff --git a/include/boost/utility/string_view.hpp b/include/boost/utility/string_view.hpp index 44efda9..11aa801 100644 --- a/include/boost/utility/string_view.hpp +++ b/include/boost/utility/string_view.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -690,6 +691,10 @@ namespace boost { } #endif + template + std::size_t hash_value(basic_string_view s) { + return boost::hash_range(s.begin(), s.end()); + } } #if 0 diff --git a/operators.htm b/operators.htm index 993436c..db81fd3 100644 --- a/operators.htm +++ b/operators.htm @@ -1586,7 +1586,7 @@ T operator+( T lhs, const T& rhs )

Arithmetic Operators Demonstration and Test Program

-

The operators_test.cpp +

The operators_test.cpp program demonstrates the use of the arithmetic operator templates, and can also be used to verify correct operation. Check the compiler status report for the test results with selected platforms.

@@ -1998,7 +1998,7 @@ struct function_output_iterator

Iterator Demonstration and Test Program

-

The iterators_test.cpp +

The iterators_test.cpp program demonstrates the use of the iterator templates, and can also be used to verify correct operation. The following is the custom iterator defined in the test program. It demonstrates a correct (though trivial) @@ -2064,7 +2064,7 @@ public:

Beman Dawes
Contributed operators_test.cpp.
+ "test/operators_test.cpp">operators_test.cpp.
Daryle Walker
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 7fd5b2f..739edc0 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -16,6 +16,7 @@ run binary_test.cpp ; run call_traits_test.cpp : -u ; run compressed_pair_test.cpp ; +run compressed_pair_final_test.cpp ; run iterators_test.cpp ; diff --git a/test/compressed_pair_final_test.cpp b/test/compressed_pair_final_test.cpp new file mode 100644 index 0000000..247f3fc --- /dev/null +++ b/test/compressed_pair_final_test.cpp @@ -0,0 +1,55 @@ +/* +Copyright 2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#if !defined(BOOST_NO_CXX11_FINAL) +#include +#include + +struct type1 { + operator bool() const { + return false; + } +}; + +struct type2 final { + operator bool() const { + return false; + } +}; + +#if !defined(BOOST_IS_FINAL) +namespace boost { + +template<> +struct is_final + : true_type { }; + +} /* boost*/ +#endif + +template +void test() +{ + boost::compressed_pair p; + BOOST_TEST(!p.first()); + BOOST_TEST(!p.second()); +} + +int main() +{ + test(); + test(); + test(); + return boost::report_errors(); +} +#else +int main() +{ + return 0; +} +#endif diff --git a/test/string_ref_test2.cpp b/test/string_ref_test2.cpp index ccb5d6d..d733775 100644 --- a/test/string_ref_test2.cpp +++ b/test/string_ref_test2.cpp @@ -93,6 +93,10 @@ void find ( const char *arg ) { string_ref sr2; const char *p; +// When we search for the empty string, we find it at position 0 + BOOST_TEST ( sr1.find (sr2) == 0 ); + BOOST_TEST ( sr1.rfind(sr2) == 0 ); + // Look for each character in the string(searching from the start) p = arg; sr1 = arg; diff --git a/test/string_view_test1.cpp b/test/string_view_test1.cpp index 9b70a7e..c35bbfa 100644 --- a/test/string_view_test1.cpp +++ b/test/string_view_test1.cpp @@ -12,6 +12,7 @@ #include #include +#include #include @@ -85,6 +86,14 @@ void test_remove ( const std::string &str ) { } } +void test_hash(const std::string& str) { + string_view ref = str; + BOOST_TEST(boost::hash_value(ref) == boost::hash_value(str)); + boost::hash hstr; + boost::hash hsv; + BOOST_TEST(hsv(ref) == hstr(str)); + } + const char *test_strings [] = { "", "1", @@ -102,6 +111,7 @@ int main() test_substr ( *p ); test_remove ( *p ); null_tests ( *p ); + test_hash( *p ); p++; } diff --git a/test/string_view_test2.cpp b/test/string_view_test2.cpp index 2549e64..135fd1a 100644 --- a/test/string_view_test2.cpp +++ b/test/string_view_test2.cpp @@ -97,6 +97,10 @@ void find ( const char *arg ) { string_view sr2; const char *p; +// When we search for the empty string, we find it at position 0 + BOOST_TEST ( sr1.find (sr2) == 0 ); + BOOST_TEST ( sr1.rfind(sr2) == 0 ); + // Look for each character in the string(searching from the start) p = arg; sr1 = arg;