forked from boostorg/bind
Fixed to compile
[SVN r37357]
This commit is contained in:
@@ -31,32 +31,18 @@
|
|||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// default implementation of visit_each
|
//
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
template<class V, class T> void visit_each(V & v, T const & t, long)
|
|
||||||
{
|
|
||||||
v(t, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// visitor
|
|
||||||
|
|
||||||
int hash = 0;
|
|
||||||
|
|
||||||
struct visitor
|
struct visitor
|
||||||
{
|
{
|
||||||
template<class T> void operator()(boost::reference_wrapper<T> const & r, int) const
|
template<class T> void operator()( boost::reference_wrapper<T> const & r ) const
|
||||||
{
|
{
|
||||||
std::cout << "Reference to " << typeid(T).name() << " @ " << &r.get() << " (with value " << r.get() << ")\n";
|
std::cout << "Reference to " << typeid(T).name() << " @ " << &r.get() << " (with value " << r.get() << ")\n";
|
||||||
hash += r.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T> void operator()(T const &, long) const
|
template<class T> void operator()( T const & t ) const
|
||||||
{
|
{
|
||||||
std::cout << "Value of type " << typeid(T).name() << '\n';
|
std::cout << "Value of type " << typeid(T).name() << " (with value " << t << ")\n";
|
||||||
++hash;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,26 +56,10 @@ int f(int & i, int & j, int)
|
|||||||
int x = 2;
|
int x = 2;
|
||||||
int y = 7;
|
int y = 7;
|
||||||
|
|
||||||
int detect_errors(bool x)
|
|
||||||
{
|
|
||||||
if(x)
|
|
||||||
{
|
|
||||||
std::cerr << "no errors detected.\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cerr << "test failed.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
visitor v;
|
visitor v;
|
||||||
visit_each(v, bind<int>(bind(f, ref(x), _1, 42), ref(y)), 0);
|
visit_each(v, bind<int>(bind(f, ref(x), _1, 42), ref(y)), 0);
|
||||||
|
|
||||||
return detect_errors(hash == 12);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user