Merge branch 'develop' (early part)

This commit is contained in:
Daniel James
2016-06-26 20:32:22 +01:00
10 changed files with 158 additions and 11 deletions

47
.travis.yml Normal file
View File

@ -0,0 +1,47 @@
# Copyright (C) 2016 Daniel James.
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# Use Trusty to get a reasonably recent version of Boost.
sudo: required
dist: trusty
language: c++
addons:
apt:
packages:
- libboost-dev
- libboost-tools-dev
matrix:
include:
- compiler: gcc
env: BJAM_TOOLSET=gcc
- compiler: gcc
env: BJAM_TOOLSET=gcc-std11
- compiler: clang
env: BJAM_TOOLSET=clang
- compiler: clang
env: BJAM_TOOLSET=clang-std11
before_script:
- |
echo "using gcc : : g++-4.8 ;" > ~/user-config.jam
echo "using gcc : std11 : g++-4.8 --std=c++11 ;" >> ~/user-config.jam
echo "using clang : : clang++ ;" >> ~/user-config.jam
echo "using clang : std11 : clang++ --std=c++11 ;" >> ~/user-config.jam
- cat ~/user-config.jam
- touch Jamroot.jam
script:
- cd ${TRAVIS_BUILD_DIR}/test
- bjam -q ${BJAM_TOOLSET} include=${TRAVIS_BUILD_DIR}/include
- cd ${TRAVIS_BUILD_DIR}/hash/test
- bjam -q ${BJAM_TOOLSET} include=${TRAVIS_BUILD_DIR}/include
- cd ${TRAVIS_BUILD_DIR}/forward/test
- bjam -q ${BJAM_TOOLSET} include=${TRAVIS_BUILD_DIR}/include
- cd ${TRAVIS_BUILD_DIR}/factory/test
- bjam -q ${BJAM_TOOLSET} include=${TRAVIS_BUILD_DIR}/include
- cd ${TRAVIS_BUILD_DIR}/overloaded_function/test
- bjam -q ${BJAM_TOOLSET} include=${TRAVIS_BUILD_DIR}/include

View File

@ -44,6 +44,10 @@ public:
{
return -(l=r+val);
}
char operator()(int& l, int& r)
{
return l=r+val;
}
template <typename Sig>
struct result
@ -89,8 +93,11 @@ int main()
// lvalue,lvalue
BOOST_TEST(( is_same<
result_of< f(int&, int&) >::type, char >::value ));
// result_of works differently for C++11 here, so compare
// with using it against test_func.
BOOST_TEST(( is_same<
result_of< f const (int&, int&) >::type, char >::value ));
result_of< f const (int&, int&) >::type,
result_of< test_func<> const (int&, int&)>::type >::value ));
}
{

View File

@ -44,6 +44,10 @@ public:
{
return -(l=r+val);
}
char operator()(int & l, int & r)
{
return l=r+val;
}
template <typename Sig>
struct result
@ -91,8 +95,11 @@ int main()
// lvalue,lvalue
BOOST_TEST(( is_same<
result_of< f(ref, ref) >::type, char >::value ));
// result_of works differently for C++11 here, so compare
// with using it against test_func.
BOOST_TEST(( is_same<
result_of< f const (ref, ref) >::type, char >::value ));
result_of< f const (ref, ref) >::type,
result_of< test_func<> const (int&, int&) >::type >::value ));
}
{
using boost::noncopyable;

View File

@ -3,6 +3,11 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// Force use of assert.
#if defined(NDEBUG)
#undef NDEBUG
#endif
#include <boost/functional/hash.hpp>
#include <cassert>

View File

@ -3,6 +3,11 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// Force use of assert.
#if defined(NDEBUG)
#undef NDEBUG
#endif
#include <boost/functional/hash.hpp>
#include <cassert>

View File

@ -58,8 +58,6 @@ void numeric_extra_tests(typename
template <class T>
void numeric_test(T*)
{
typedef boost::hash_detail::limits<T> limits;
compile_time_tests((T*) 0);
BOOST_HASH_TEST_NAMESPACE::hash<T> x1;

View File

@ -38,6 +38,23 @@ void string_tests()
#endif
}
void string0_tests()
{
std::string x1(1, '\0');
std::string x2(2, '\0');
std::string x3(3, '\0');
std::string x4(10, '\0');
BOOST_HASH_TEST_NAMESPACE::hash<std::string> hasher;
BOOST_TEST(hasher(x1) != hasher(x2));
BOOST_TEST(hasher(x1) != hasher(x3));
BOOST_TEST(hasher(x1) != hasher(x4));
BOOST_TEST(hasher(x2) != hasher(x3));
BOOST_TEST(hasher(x2) != hasher(x4));
BOOST_TEST(hasher(x3) != hasher(x4));
}
#if !defined(BOOST_NO_STD_WSTRING)
void wstring_tests()
{
@ -66,6 +83,7 @@ void wstring_tests()
int main()
{
string_tests();
string0_tests();
#if !defined(BOOST_NO_STD_WSTRING)
wstring_tests();
#endif

View File

@ -144,8 +144,30 @@ namespace boost
: boost::result_of< BOOST_DEDUCED_TYPENAME c<Self>::t() >
{ };
template< class MD, class F, class FC >
struct forward_adapter_impl<MD,F,FC,0,0>
// WHen operator()() doesn't have any parameters, it can't
// be templatized and can't use SFINAE, so intead use class
// template parameter SFINAE to decide whether to instantiate it.
template <typename T, typename R = void>
struct forward_adapter_sfinae
{
typedef T type;
};
// This is the fallback for when there isn't an operator()(),
// need to create an operator() that will never instantiate
// so that using parent::operator() will work okay.
template< class MD, class F, class FC, class Enable = void>
struct forward_adapter_impl_zero
{
template <typename T> struct never_instantiate {};
template <typename T>
typename never_instantiate<T>::type operator()(T) const {}
};
template< class MD, class F, class FC>
struct forward_adapter_impl_zero<MD, F, FC,
typename forward_adapter_sfinae<typename boost::result_of< FC() >::type>::type>
{
inline typename boost::result_of< FC() >::type
operator()() const
@ -158,6 +180,13 @@ namespace boost
{
return static_cast<MD*>(this)->target_function()();
}
};
template< class MD, class F, class FC >
struct forward_adapter_impl<MD,F,FC,0,0>
: forward_adapter_impl_zero<MD,F,FC>
{
using forward_adapter_impl_zero<MD,F,FC>::operator();
// closing brace gets generated by preprocessing code, below

View File

@ -212,7 +212,6 @@ namespace boost
seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2);
}
template <typename SizeT>
inline void hash_combine_impl(boost::uint32_t& h1,
boost::uint32_t k1)
{
@ -229,12 +228,11 @@ namespace boost
}
// Don't define 64-bit hash combine on platforms with 64 bit integers,
// Don't define 64-bit hash combine on platforms without 64 bit integers,
// and also not for 32-bit gcc as it warns about the 64-bit constant.
#if !defined(BOOST_NO_INT64_T) && \
!(defined(__GNUC__) && ULONG_MAX == 0xffffffff)
template <typename SizeT>
inline void hash_combine_impl(boost::uint64_t& h,
boost::uint64_t k)
{
@ -247,6 +245,10 @@ namespace boost
h ^= k;
h *= m;
// Completely arbitrary number, to prevent 0's
// from hashing to 0.
h += 0xe6546b64;
}
#endif // BOOST_NO_INT64_T

View File

@ -149,8 +149,31 @@ namespace boost
: boost::result_of< BOOST_DEDUCED_TYPENAME c<Self>::t() >
{ };
template< class MD, class F, class FC >
struct lightweight_forward_adapter_impl<MD,F,FC,0,0>
// When operator() doesn't have any parameters, it can't
// be templatized and can't use SFINAE, so intead use class
// template parameter SFINAE to decide whether to instantiate it.
template <typename T, typename R = void>
struct lightweight_forward_adapter_sfinae
{
typedef T type;
};
// This is the fallback for when there isn't an operator()(),
// need to create an operator() that will never instantiate
// so that using parent::operator() will work okay.
template< class MD, class F, class FC, class Enable = void>
struct lightweight_forward_adapter_impl_zero
: lightweight_forward_adapter_result
{
template <typename T> struct never_instantiate {};
template <typename T>
typename never_instantiate<T>::type operator()(T) const {}
};
template< class MD, class F, class FC>
struct lightweight_forward_adapter_impl_zero<MD, F, FC,
typename lightweight_forward_adapter_sfinae<typename boost::result_of< FC() >::type>::type>
: lightweight_forward_adapter_result
{
inline typename boost::result_of< FC() >::type
@ -166,6 +189,12 @@ namespace boost
}
};
template< class MD, class F, class FC >
struct lightweight_forward_adapter_impl<MD,F,FC,0,0>
: lightweight_forward_adapter_impl_zero<MD,F,FC>
{
};
# define BOOST_PP_FILENAME_1 \
<boost/functional/lightweight_forward_adapter.hpp>
# define BOOST_PP_ITERATION_LIMITS \