mirror of
https://github.com/boostorg/utility.git
synced 2025-08-01 05:44:37 +02:00
Merge branch 'develop'
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -493,7 +493,7 @@ call_traits can not be used with reference or array types.</p>
|
||||
<h4>Example 1:</h4>
|
||||
|
||||
<p>The following class is a trivial class that stores some type T
|
||||
by value (see the <a href="call_traits_test.cpp">call_traits_test.cpp</a>
|
||||
by value (see the <a href="test/call_traits_test.cpp">call_traits_test.cpp</a>
|
||||
file), the aim is to illustrate how each of the available
|
||||
call_traits typedefs may be used:</p>
|
||||
|
||||
|
@@ -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]
|
||||
|
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/is_empty.hpp>
|
||||
#include <boost/type_traits/is_final.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
|
||||
@@ -42,6 +43,14 @@ class compressed_pair;
|
||||
|
||||
namespace details
|
||||
{
|
||||
template<class T, bool E = boost::is_final<T>::value>
|
||||
struct compressed_pair_empty
|
||||
: ::boost::false_type { };
|
||||
|
||||
template<class T>
|
||||
struct compressed_pair_empty<T, false>
|
||||
: ::boost::is_empty<T> { };
|
||||
|
||||
// JM altered 26 Jan 2000:
|
||||
template <class T1, class T2, bool IsSame, bool FirstEmpty, bool SecondEmpty>
|
||||
struct compressed_pair_switch;
|
||||
@@ -343,8 +352,8 @@ class compressed_pair
|
||||
T1,
|
||||
T2,
|
||||
::boost::is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
|
||||
::boost::is_empty<T1>::value,
|
||||
::boost::is_empty<T2>::value>::value>
|
||||
::boost::details::compressed_pair_empty<T1>::value,
|
||||
::boost::details::compressed_pair_empty<T2>::value>::value>
|
||||
{
|
||||
private:
|
||||
typedef details::compressed_pair_imp<T1, T2,
|
||||
@@ -352,8 +361,8 @@ private:
|
||||
T1,
|
||||
T2,
|
||||
::boost::is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
|
||||
::boost::is_empty<T1>::value,
|
||||
::boost::is_empty<T2>::value>::value> base;
|
||||
::boost::details::compressed_pair_empty<T1>::value,
|
||||
::boost::details::compressed_pair_empty<T2>::value>::value> base;
|
||||
public:
|
||||
typedef T1 first_type;
|
||||
typedef T2 second_type;
|
||||
@@ -388,8 +397,8 @@ class compressed_pair<T, T>
|
||||
T,
|
||||
T,
|
||||
::boost::is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
|
||||
::boost::is_empty<T>::value,
|
||||
::boost::is_empty<T>::value>::value>
|
||||
::boost::details::compressed_pair_empty<T>::value,
|
||||
::boost::details::compressed_pair_empty<T>::value>::value>
|
||||
{
|
||||
private:
|
||||
typedef details::compressed_pair_imp<T, T,
|
||||
@@ -397,8 +406,8 @@ private:
|
||||
T,
|
||||
T,
|
||||
::boost::is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
|
||||
::boost::is_empty<T>::value,
|
||||
::boost::is_empty<T>::value>::value> base;
|
||||
::boost::details::compressed_pair_empty<T>::value,
|
||||
::boost::details::compressed_pair_empty<T>::value>::value> base;
|
||||
public:
|
||||
typedef T first_type;
|
||||
typedef T second_type;
|
||||
|
@@ -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());
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/utility/string_view_fwd.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
@@ -690,6 +691,10 @@ namespace boost {
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class charT, class traits>
|
||||
std::size_t hash_value(basic_string_view<charT, traits> s) {
|
||||
return boost::hash_range(s.begin(), s.end());
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@@ -1586,7 +1586,7 @@ T operator+( T lhs, const T& rhs )
|
||||
<h3><a name="a_demo">Arithmetic Operators Demonstration</a> and Test
|
||||
Program</h3>
|
||||
|
||||
<p>The <cite><a href="operators_test.cpp">operators_test.cpp</a></cite>
|
||||
<p>The <cite><a href="test/operators_test.cpp">operators_test.cpp</a></cite>
|
||||
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.</p>
|
||||
@@ -1998,7 +1998,7 @@ struct function_output_iterator
|
||||
|
||||
<h3><a name="i_demo">Iterator Demonstration</a> and Test Program</h3>
|
||||
|
||||
<p>The <cite><a href="iterators_test.cpp">iterators_test.cpp</a></cite>
|
||||
<p>The <cite><a href="test/iterators_test.cpp">iterators_test.cpp</a></cite>
|
||||
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:
|
||||
<dt><a href="http://www.boost.org/people/beman_dawes.html">Beman Dawes</a></dt>
|
||||
|
||||
<dd>Contributed <cite><a href=
|
||||
"operators_test.cpp">operators_test.cpp</a></cite>.</dd>
|
||||
"test/operators_test.cpp">operators_test.cpp</a></cite>.</dd>
|
||||
|
||||
<dt><a href="http://www.boost.org/people/daryle_walker.html">Daryle Walker</a></dt>
|
||||
|
||||
|
@@ -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 ;
|
||||
|
||||
|
55
test/compressed_pair_final_test.cpp
Normal file
55
test/compressed_pair_final_test.cpp
Normal file
@@ -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 <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_FINAL)
|
||||
#include <boost/compressed_pair.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
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<type2>
|
||||
: true_type { };
|
||||
|
||||
} /* boost*/
|
||||
#endif
|
||||
|
||||
template<class T1, class T2>
|
||||
void test()
|
||||
{
|
||||
boost::compressed_pair<T1, T2> p;
|
||||
BOOST_TEST(!p.first());
|
||||
BOOST_TEST(!p.second());
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<type1, type2>();
|
||||
test<type2, type1>();
|
||||
test<type2, type2>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
@@ -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;
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include <string>
|
||||
|
||||
#include <boost/utility/string_view.hpp>
|
||||
#include <boost/container_hash/hash.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
@@ -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<std::string> hstr;
|
||||
boost::hash<string_view> 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++;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user