From 3c56630b5400c43d1a4393d685a407e68a69ce9e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 Aug 2016 01:28:49 +0300 Subject: [PATCH 1/6] SFINAE out the converting constructor of arg to avoid hard errors with is_convertible on g++ 4.8/4.9 --- include/boost/bind/arg.hpp | 13 +++++++-- test/Jamfile.v2 | 3 ++ test/arg_copy_fail.cpp | 19 ++++++++++++ test/arg_copy_test.cpp | 34 ++++++++++++++++++++++ test/placeholder_std_bind_test.cpp | 46 ++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 test/arg_copy_fail.cpp create mode 100644 test/arg_copy_test.cpp create mode 100644 test/placeholder_std_bind_test.cpp diff --git a/include/boost/bind/arg.hpp b/include/boost/bind/arg.hpp index a74b829..71e008d 100644 --- a/include/boost/bind/arg.hpp +++ b/include/boost/bind/arg.hpp @@ -21,20 +21,27 @@ #include #include -#include namespace boost { +template< int I, int J > struct _arg_eq +{ +}; + +template< int I > struct _arg_eq< I, I> +{ + typedef void type; +}; + template< int I > struct arg { BOOST_CONSTEXPR arg() { } - template< class T > BOOST_CONSTEXPR arg( T const & /* t */ ) + template< class T > BOOST_CONSTEXPR arg( T const & /* t */, typename _arg_eq< I, is_placeholder::value >::type * = 0 ) { - BOOST_STATIC_ASSERT( I == is_placeholder::value ); } }; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 179d1d1..3c0d84b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -56,4 +56,7 @@ test-suite "bind" [ run bind_type_test.cpp ] [ run bind_unique_ptr_test.cpp ] [ run bind_nested_rv_test.cpp ] + [ compile arg_copy_test.cpp ] + [ compile-fail arg_copy_fail.cpp ] + [ run placeholder_std_bind_test.cpp ] ; diff --git a/test/arg_copy_fail.cpp b/test/arg_copy_fail.cpp new file mode 100644 index 0000000..35e9e3d --- /dev/null +++ b/test/arg_copy_fail.cpp @@ -0,0 +1,19 @@ +// +// arg_copy_fail.cpp - arg<1> to arg<2> +// +// Copyright 2016 Peter Dimov +// +// 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 +// + +#include + +// + +int main() +{ + boost::arg<1> a1(( boost::arg<2>() )); + (void)a1; +} diff --git a/test/arg_copy_test.cpp b/test/arg_copy_test.cpp new file mode 100644 index 0000000..b727ce6 --- /dev/null +++ b/test/arg_copy_test.cpp @@ -0,0 +1,34 @@ +// +// arg_copy_test.cpp - copying a custom placeholder _1 to arg<1> +// +// Copyright 2016 Peter Dimov +// +// 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 +// + +#include +#include + +// + +template struct ph +{ +}; + +namespace boost +{ + +template struct is_placeholder< ::ph > +{ + enum _vt { value = I }; +}; + +} // namespace boost + +int main() +{ + boost::arg<1> a1 = ph<1>(); + (void)a1; +} diff --git a/test/placeholder_std_bind_test.cpp b/test/placeholder_std_bind_test.cpp new file mode 100644 index 0000000..3034b8e --- /dev/null +++ b/test/placeholder_std_bind_test.cpp @@ -0,0 +1,46 @@ +// +// placeholder_std_bind_test.cpp - std::bind with Boost's _1 +// +// Copyright 2016 Peter Dimov +// +// 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 +// + +#include + +#if defined( BOOST_NO_CXX11_HDR_FUNCTIONAL ) + +int main() +{ +} + +#else + +#include +#include +#include + +namespace std +{ + +template struct is_placeholder< boost::arg >: public integral_constant {}; + +} // namespace std + +int foo( int i ) +{ + return i; +} + +int main() +{ + BOOST_TEST_EQ( std::bind( foo, _1 )( 1 ), 1 ); + BOOST_TEST_EQ( std::bind( foo, _2 )( 1, 2 ), 2 ); + BOOST_TEST_EQ( std::bind( foo, _3 )( 1, 2, 3 ), 3 ); + + return boost::report_errors(); +} + +#endif From 808996b70f4403bd47ebd5dc150e7ec0a4637bc4 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 20 Aug 2016 02:00:14 +0300 Subject: [PATCH 2/6] Replace msvc-12.0 with msvc-14.0 in Appveyor, as 12.0 doesn't seem to work --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 8c69778..7d10a80 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -42,4 +42,4 @@ install: build: off test_script: - - b2 libs/bind/test toolset=msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0 + - b2 libs/bind/test toolset=msvc-9.0,msvc-10.0,msvc-11.0,msvc-14.0 From 03a25d41dab4873a37164479603c72f0e27ca168 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 28 Aug 2016 23:17:16 +0300 Subject: [PATCH 3/6] Enable Travis notifications on success --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5ee2e0a..cfbf381 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,3 +47,7 @@ script: - TOOLSET=gcc,clang - if [ $TRAVIS_OS_NAME == osx ]; then TOOLSET=clang; fi - ./b2 libs/bind/test toolset=$TOOLSET + +notifications: + email: + on_success: always From a1f6206a4958a1cd5a14e84139790b9b27ac3e41 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 10 Sep 2016 13:04:05 +0300 Subject: [PATCH 4/6] Do not checkout libs/bind, copy, because of pull requests. --- appveyor.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7d10a80..02fe282 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,9 +12,9 @@ branches: - develop install: - - git clone -b %APPVEYOR_REPO_BRANCH% https://github.com/boostorg/boost.git boost - - cd boost - - git submodule init libs/bind + - cd .. + - git clone -b %APPVEYOR_REPO_BRANCH% https://github.com/boostorg/boost.git boost-root + - cd boost-root - git submodule init libs/align - git submodule init libs/assert - git submodule init libs/config @@ -34,7 +34,7 @@ install: - git submodule init tools/inspect - git submodule update - cd libs\bind - - git checkout -q %APPVEYOR_REPO_COMMIT% + - xcopy %APPVEYOR_BUILD_FOLDER% /s /e /q - cd ..\.. - bootstrap - b2 headers From 473155eebe002fffb85d913b997be7725258b119 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 10 Sep 2016 13:21:11 +0300 Subject: [PATCH 5/6] Update .travis.yml to not checkout as well. --- .travis.yml | 10 ++++------ appveyor.yml | 4 +--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index cfbf381..1d32efa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,9 @@ branches: - develop install: - - git clone -b $TRAVIS_BRANCH https://github.com/boostorg/boost.git boost - - cd boost - - git submodule init libs/bind + - cd .. + - git clone -b $TRAVIS_BRANCH https://github.com/boostorg/boost.git boost-root + - cd boost-root - git submodule init libs/align - git submodule init libs/assert - git submodule init libs/config @@ -37,9 +37,7 @@ install: - git submodule init tools/build - git submodule init tools/inspect - git submodule update - - cd libs/bind - - git checkout -q $TRAVIS_COMMIT - - cd ../.. + - cp -r $TRAVIS_BUILD_DIR/* libs/bind - ./bootstrap.sh - ./b2 headers diff --git a/appveyor.yml b/appveyor.yml index 02fe282..5aa53fc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,9 +33,7 @@ install: - git submodule init tools/build - git submodule init tools/inspect - git submodule update - - cd libs\bind - - xcopy %APPVEYOR_BUILD_FOLDER% /s /e /q - - cd ..\.. + - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\bind - bootstrap - b2 headers From c61026bb81002ffff9d1e13cda9b6277f1239f15 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 10 Sep 2016 13:42:05 +0300 Subject: [PATCH 6/6] Simplify _arg_eq, avoid partial specialization. --- include/boost/bind/arg.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/bind/arg.hpp b/include/boost/bind/arg.hpp index 71e008d..cb52e66 100644 --- a/include/boost/bind/arg.hpp +++ b/include/boost/bind/arg.hpp @@ -25,11 +25,11 @@ namespace boost { -template< int I, int J > struct _arg_eq +template struct _arg_eq { }; -template< int I > struct _arg_eq< I, I> +template<> struct _arg_eq { typedef void type; }; @@ -40,7 +40,7 @@ template< int I > struct arg { } - template< class T > BOOST_CONSTEXPR arg( T const & /* t */, typename _arg_eq< I, is_placeholder::value >::type * = 0 ) + template< class T > BOOST_CONSTEXPR arg( T const & /* t */, typename _arg_eq< I == is_placeholder::value >::type * = 0 ) { } };