-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SFINAE out the converting constructor of arg<I> to avoid hard errors …
…with is_convertible on g++ 4.8/4.9
- Loading branch information
Showing
5 changed files
with
112 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |