1
0
forked from boostorg/bind

Merge branch 'develop'

This commit is contained in:
Peter Dimov
2016-09-30 16:00:20 +03:00
7 changed files with 125 additions and 16 deletions

View File

@@ -16,9 +16,9 @@ branches:
- develop - develop
install: install:
- git clone -b $TRAVIS_BRANCH https://github.com/boostorg/boost.git boost - cd ..
- cd boost - git clone -b $TRAVIS_BRANCH https://github.com/boostorg/boost.git boost-root
- git submodule init libs/bind - cd boost-root
- git submodule init libs/align - git submodule init libs/align
- git submodule init libs/assert - git submodule init libs/assert
- git submodule init libs/config - git submodule init libs/config
@@ -37,9 +37,7 @@ install:
- git submodule init tools/build - git submodule init tools/build
- git submodule init tools/inspect - git submodule init tools/inspect
- git submodule update - git submodule update
- cd libs/bind - cp -r $TRAVIS_BUILD_DIR/* libs/bind
- git checkout -q $TRAVIS_COMMIT
- cd ../..
- ./bootstrap.sh - ./bootstrap.sh
- ./b2 headers - ./b2 headers
@@ -47,3 +45,7 @@ script:
- TOOLSET=gcc,clang - TOOLSET=gcc,clang
- if [ $TRAVIS_OS_NAME == osx ]; then TOOLSET=clang; fi - if [ $TRAVIS_OS_NAME == osx ]; then TOOLSET=clang; fi
- ./b2 libs/bind/test toolset=$TOOLSET - ./b2 libs/bind/test toolset=$TOOLSET
notifications:
email:
on_success: always

View File

@@ -12,9 +12,9 @@ branches:
- develop - develop
install: install:
- git clone -b %APPVEYOR_REPO_BRANCH% https://github.com/boostorg/boost.git boost - cd ..
- cd boost - git clone -b %APPVEYOR_REPO_BRANCH% https://github.com/boostorg/boost.git boost-root
- git submodule init libs/bind - cd boost-root
- git submodule init libs/align - git submodule init libs/align
- git submodule init libs/assert - git submodule init libs/assert
- git submodule init libs/config - git submodule init libs/config
@@ -33,13 +33,11 @@ install:
- git submodule init tools/build - git submodule init tools/build
- git submodule init tools/inspect - git submodule init tools/inspect
- git submodule update - git submodule update
- cd libs\bind - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\bind
- git checkout -q %APPVEYOR_REPO_COMMIT%
- cd ..\..
- bootstrap - bootstrap
- b2 headers - b2 headers
build: off build: off
test_script: 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

View File

@@ -21,20 +21,27 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/is_placeholder.hpp> #include <boost/is_placeholder.hpp>
#include <boost/static_assert.hpp>
namespace boost namespace boost
{ {
template<bool Eq> struct _arg_eq
{
};
template<> struct _arg_eq<true>
{
typedef void type;
};
template< int I > struct arg template< int I > struct arg
{ {
BOOST_CONSTEXPR 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<T>::value >::type * = 0 )
{ {
BOOST_STATIC_ASSERT( I == is_placeholder<T>::value );
} }
}; };

View File

@@ -56,4 +56,7 @@ test-suite "bind"
[ run bind_type_test.cpp ] [ run bind_type_test.cpp ]
[ run bind_unique_ptr_test.cpp ] [ run bind_unique_ptr_test.cpp ]
[ run bind_nested_rv_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 ]
; ;

19
test/arg_copy_fail.cpp Normal file
View File

@@ -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 <boost/bind/arg.hpp>
//
int main()
{
boost::arg<1> a1(( boost::arg<2>() ));
(void)a1;
}

34
test/arg_copy_test.cpp Normal file
View File

@@ -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 <boost/is_placeholder.hpp>
#include <boost/bind/arg.hpp>
//
template<int I> struct ph
{
};
namespace boost
{
template<int I> struct is_placeholder< ::ph<I> >
{
enum _vt { value = I };
};
} // namespace boost
int main()
{
boost::arg<1> a1 = ph<1>();
(void)a1;
}

View File

@@ -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 <boost/config.hpp>
#if defined( BOOST_NO_CXX11_HDR_FUNCTIONAL )
int main()
{
}
#else
#include <boost/bind.hpp>
#include <boost/core/lightweight_test.hpp>
#include <functional>
namespace std
{
template<int N> struct is_placeholder< boost::arg<N> >: public integral_constant<int, N> {};
} // 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