A Problem with boost::bind
::basic_ios(const std::basic_ios<char, std::char_traits<char> >&)': E:/Print.cpp:33: instantiated from `std::ostream&
, unsigned int i = 2]' E:/Print.cpp:72: instantiated from here C:/Dev-Cpp/include/c++/3.3.1/bits/ios_base.h:668: error: ` std::ios_base::ios_base(const std::ios_base&)' is
, unsigned int i = 2]': E:/Print.cpp:72: instantiated from here E:/Print.cpp:33: error: initializing argument 3 of ` boost::_bi::bind_t<boost::_bi::unspecified, F, typename boost::_bi::list_av_2<A1, A2>::type> boost::bind(F, A1, A2) [with F =
, unsigned int i = 2]' E:/Print.cpp:72: instantiated from here C:/Dev-Cpp/include/boost/bind.hpp:62: error: no type named `result_type' in ` struct print<std::vector<int, std::allocator<int> , 1>' C:/Dev-Cpp/include/boost/bind/bind_template.hpp: In instantiation of `boost::_bi::bind_t<boost::_bi::unspecified,
, unsigned int i = 2]' E:/Print.cpp:72: instantiated from here C:/Dev-Cpp/include/boost/bind/bind_template.hpp:16: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified,
Dear all, A fragment of code of mine is like this: template <class Container, size_t i> struct print { ostream& operator () (const Container& c, ostream& out) const { if(out) { typedef typename Container::value_type value_type; typedef print<value_type, i - 1> NewPrint; NewPrint newPrint; for(typename Container::const_iterator j = c.begin(); j != c.end(); ++j) newPrint(*j, out); /*for_each(c.begin(), c.end(), bind(newPrint, _2, out)); //Error!*/ } return out; } }; AFAICS, there should be no harm in replacing that for with the for_each in the comments -- the one is marked with "//Error" I mean, except that "out" which is of type ostream& is not Copy-Constructible, and therefore _2 cannot be used against it. Anybody having a workarounds for that? Doesn't Boost have anything analog to boost::ref which can give me a Copy-Constructible beast? For your reference, you can find the whole program and the compiler error message in the P.S. TIA, --Hossein P.S. #include <iostream> #include <algorithm> #include <iterator> #include <vector> #include <boost/bind.hpp> #include <boost/mem_fn.hpp> using std::ostream; using std::cin; using std::cout; using std::copy; using std::for_each; using std::ostream_iterator; using std::vector; using boost::bind; using boost::mem_fn; template <class Container, size_t i> struct print { ostream& operator () (const Container& c, ostream& out) const { if(out) { typedef typename Container::value_type value_type; typedef print<value_type, i - 1> NewPrint; NewPrint newPrint; /* for(typename Container::const_iterator j = c.begin(); j != c.end(); ++j) newPrint(*j, out); */ for_each(c.begin(), c.end(), bind(newPrint, _2, out)); //Error! } return out; } }; template <class Container> struct print<Container, 1> { ostream& operator () (const Container& c, ostream& out) const { if(out) copy(c.begin(), c.end(), ostream_iterator<typename Container::value_type>(out, " ")); return out; } ostream& DoIt (const Container& c, ostream& out) const { if(out) copy(c.begin(), c.end(), ostream_iterator<typename Container::value_type>(out, " ")); return out; } }; int main() { int a1[] = {1, 2, 3, 4}; const size_t n(sizeof(a1)/sizeof(*a1)); vector<int> v(a1, a1 + n); print<vector<int>, 1> () (v, cout); int a2[n] = {5, 6, 7, 8}; vector<vector<int> > m; m.push_back(v); m.push_back(vector<int>(a2, a2 + n)); print<vector<vector<int> >, 2> () (m, cout); cin.get(); return 0; } Compiler: Default compiler Executing g++.exe... g++.exe "E:\Print.cpp" -o "E:\Print.exe" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" C:/Dev-Cpp/include/c++/3.3.1/bits/ios_base.h: In copy constructor ` std::basic_ios<char, std::char_traits<char> print<Container, i>::operator()(const Container&, std::ostream&) const [with Container = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > private E:/Print.cpp:33: error: within this context E:/Print.cpp: In member function `std::ostream& print<Container, i>::operator()(const Container&, std::ostream&) const [with Container = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> print<std::vector<int, std::allocator<int> >, 1>, A1 = boost::arg<2>, A2 = std::basic_ostream<char, std::char_traits<char> >]' C:/Dev-Cpp/include/boost/bind.hpp: At global scope: C:/Dev-Cpp/include/boost/bind.hpp: In instantiation of `boost::_bi::result_traits<boost::_bi::unspecified, print<std::vector<int, std::allocator<int> >, 1> >': C:/Dev-Cpp/include/boost/bind/bind_template.hpp:16: instantiated from `boost::_bi::bind_t<boost::_bi::unspecified, print<std::vector<int, std::allocator<int> >, 1>, boost::_bi::list2<boost::arg<2>, boost::_bi::value<std::basic_ostream<char, std::char_traits<char> > > > >' E:/Print.cpp:33: instantiated from `std::ostream& print<Container, i>::operator()(const Container&, std::ostream&) const [with Container = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > print<std::vector<int, std::allocator<int> >, 1>, boost::_bi::list2<boost::arg<2>, boost::_bi::value<std::basic_ostream<char, std::char_traits<char> > > > >': E:/Print.cpp:33: instantiated from `std::ostream& print<Container, i>::operator()(const Container&, std::ostream&) const [with Container = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > print<std::vector<int, std::allocator<int> >, 1> >' C:/Dev-Cpp/include/boost/bind/bind_template.hpp:19: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, print<std::vector<int, std::allocator<int> >, 1> >' C:/Dev-Cpp/include/boost/bind/bind_template.hpp:25: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, print<std::vector<int, std::allocator<int> >, 1> >' C:/Dev-Cpp/include/boost/bind/bind_template.hpp:31: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, print<std::vector<int, std::allocator<int> >, 1> >' C:/Dev-Cpp/include/boost/bind/bind_template.hpp:31: confused by earlier errors, bailing out Execution terminated ___________________________________________________________ Switch an email account to Yahoo! Mail, you could win FIFA World Cup tickets. http://uk.mail.yahoo.com
Hossein Haeri wrote:
Dear all,
A fragment of code of mine is like this:
template <class Container, size_t i> struct print { ostream& operator () (const Container& c, ostream& out) const { if(out) { typedef typename Container::value_type value_type; typedef print<value_type, i - 1> NewPrint; NewPrint newPrint;
for(typename Container::const_iterator j = c.begin(); j != c.end(); ++j) newPrint(*j, out); /*for_each(c.begin(), c.end(), bind(newPrint, _2, out)); //Error!*/
bind( newPrint, _1, boost::ref(out) ); //untested I'm not sure why you thought you would use _2? Jeff Flinn
Hi Jeff.
bind(newPrint, _2, out));
//Error!*/
bind( newPrint, _1, boost::ref(out) ); //untested
Doesn't work! :(
I'm not sure why you thought you would use _2?
You mean it starts from 0, and the second argument should be dealed with _1? TIA, --Hossein ___________________________________________________________ Switch an email account to Yahoo! Mail, you could win FIFA World Cup tickets. http://uk.mail.yahoo.com
Hossein Haeri wrote:
Hi Jeff.
bind(newPrint, _2, out));
//Error!*/
bind( newPrint, _1, boost::ref(out) ); //untested
Doesn't work! :(
I'm not sure why you thought you would use _2?
You mean it starts from 0, and the second argument should be dealed with _1?
No, the first argument if _1. Your function object's operator(): ostream& operator ()( const Container& c, ostream& out )const has only two arguments. And bind( newPrint // instance of function object , _1 // placeholder to recieve *value_type::const_iterator , boost::ref(out) // bound reference to ostream ) is as if a function ostream& f( const value_type::value_type& _1 ) { print<value_type,i-1>()( _1, out ); } is being passed to for_each. I think your problems lie elsewhere. Try this out with simpler non-templated, non-recursive functions first. Jeff Flinn
Hi Jeff.
bind( newPrint // instance of function object , _1 // placeholder to recieve *value_type::const_iterator
Oops! Not AFAICS. Consider its equivalent for: for(typename Container::const_iterator j = c.begin(); j != c.end(); ++j) newPrint(*j, out); This means that _1 is meant to recieve *Container::const_iterator which is exactly what I pass to for_each: for_each(c.begin(), c.end(), bind(newPrint, _2, out));
I think your problems lie elsewhere. Try this out with simpler non-templated, non-recursive functions first.
Hmmm... I guess I know enough about those trivial situations. And, I need it as it is. Furthermore, the for loop works, which means that there shouldn't be ant problem any way else... :( Cheers, --Hossein ___________________________________________________________ NEW Yahoo! Cars - sell your car and browse thousands of new and used cars online! http://uk.cars.yahoo.com/
Hi, I get it (on VC++2003) as the problem being a lack of return_type typedefs. Hossein Haeri wrote:
#include <iostream> #include <algorithm> #include <iterator> #include <vector> #include <boost/bind.hpp> #include <boost/mem_fn.hpp>
using std::ostream; using std::cin; using std::cout; using std::copy; using std::for_each; using std::ostream_iterator; using std::vector; using boost::bind; using boost::mem_fn;
template <class Container, size_t i> struct print {
typedef ostream& result_type;
ostream& operator () (const Container& c, ostream& out) const { if(out) { typedef typename Container::value_type value_type; typedef print<value_type, i - 1> NewPrint; NewPrint newPrint; /* for(typename Container::const_iterator j = c.begin(); j != c.end(); ++j) newPrint(*j, out); */ for_each(c.begin(), c.end(), bind(newPrint, _2, out)); //Error! } return out; } };
template <class Container> struct print<Container, 1> {
typedef ostream& result_type;
ostream& operator () (const Container& c, ostream& out) const { if(out) copy(c.begin(), c.end(), ostream_iterator<typename Container::value_type>(out, " ")); return out; } ostream& DoIt (const Container& c, ostream& out) const { if(out) copy(c.begin(), c.end(), ostream_iterator<typename Container::value_type>(out, " ")); return out; } };
int main() { int a1[] = {1, 2, 3, 4}; const size_t n(sizeof(a1)/sizeof(*a1));
vector<int> v(a1, a1 + n); print<vector<int>, 1> () (v, cout);
int a2[n] = {5, 6, 7, 8}; vector<vector<int> > m; m.push_back(v); m.push_back(vector<int>(a2, a2 + n)); print<vector<vector<int> >, 2> () (m, cout);
cin.get(); return 0; }
Bye, Steve
Hi Steve.
I get it (on VC++2003) as the problem being a lack of return_type typedefs.
::basic_ios(const std::basic_ios<char, std::char_traits<char> >&)': Print.hpp:19: instantiated from `std::ostream& PrintAux<Container, i>::operator()(const Container&, std::ostream&) const [with Container = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> >
, unsigned int i = 2]' Print.hpp:62: instantiated from `std::ostream& Print(const T&, std::ostream&) [with T = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > ]' Print.cpp:30: instantiated from here E:/Program Files/Dev-Cpp/include/c++/3.3.1/bits/ios_base.h:668: error: ` std::ios_base::ios_base(const std::ios_base&)' is
Doesn't work for GCC 3.3.1 either! :( BTW, I have modified the files, and added your code as well. I see due to your additions the resulting errors have been changed. In case you are nice enough to take another look, see the PS please. :) Many thanks for the time you took so far! :) TTFN, --Hossein //Print.hpp #include <iterator> #include <iosfwd> #include <algorithm> template <class Container, size_t i> struct PrintAux { typedef std::ostream& return_type; std::ostream& operator () (const Container& c, std::ostream& out) const { if(out) { PrintAux<typename Container::value_type, i - 1> newPrint; /* for(typename Container::const_iterator j = c.begin(); j != c.end(); ++j) newPrint(*j, out); // */ for_each(c.begin(), c.end(), bind(newPrint, _2, out)); } return out; } }; template <class Container> struct PrintAux<Container, 1> { typedef std::ostream& return_type; std::ostream& operator () (const Container& c, std::ostream& out) const { if(out) std::copy(c.begin(), c.end(), std::ostream_iterator<typename Container::value_type>(out, " ")); return out; } }; template <class Container> struct PrintAux<Container, 0> { class ERROR_PRINT_NOT_FOR_SCALER_VARIABLES_ONLY_FOR_CONTAIERS; ERROR_PRINT_NOT_FOR_SCALER_VARIABLES_ONLY_FOR_CONTAIERS e; }; template <typename> struct ContainerDepth { enum {value = 0}; }; template <template <typename> class Container, typename T> struct ContainerDepth<Container<T> > { enum {value = ContainerDepth<typename Container<T>::value_type>::value + 1}; }; template <typename T> std::ostream& Print(const T& t, std::ostream& out) { return PrintAux<T, ContainerDepth<T>::value> () (t, out); } //Print.cpp #include <iostream> #include <vector> #include <functional> #include <algorithm> #include <boost/bind.hpp> #include "Print.hpp" using std::cin; using std::cout; using std::endl; using std::copy; using std::vector; using std::transform; using std::multiplies; using std::plus; using boost::bind; int main() { int a1[] = {1, 2, 3, 4}; const size_t n(sizeof(a1)/sizeof(*a1)); int a2[n] = {5, 6, 7, 8}; vector<int> v(a1, a1 + n); vector<vector<int> > m(1, v); m.push_back(vector<int>(a2, a2 + n)); Print(m, cout); cin.get(); return 0; } Error Message: Compiler: Default compiler Building Makefile: "E:\My Documents\My Programmes\Tests\Aarash\Makefile.win" Executing make... make.exe -f "E:\My Documents\My Programmes\Tests\Aarash\Makefile.win" all g++.exe -c Print.cpp -o Print.o -I"E:/Program Files/Dev-Cpp/include/c++/3.3.1" -I"E:/Program Files/Dev-Cpp/include/c++/3.3.1/mingw32" -I"E:/Program Files/Dev-Cpp/include/c++/3.3.1/backward" -I"E:/Program Files/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"E:/Program Files/Dev-Cpp/include" E:/Program Files/Dev-Cpp/include/c++/3.3.1/bits/ios_base.h: In copy constructor `std::basic_ios<char, std::char_traits<char> private Print.hpp:19: error: within this context Print.hpp: In member function `std::ostream& PrintAux<Container, i>::operator()(const Container&, std::ostream&) const [with Container = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int>
, unsigned int i = 2]': Print.hpp:62: instantiated from `std::ostream& Print(const T&, std::ostream&) [with T = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > ]' Print.cpp:30: instantiated from here Print.hpp:19: error: initializing argument 3 of ` boost::_bi::bind_t<boost::_bi::unspecified, F, typename boost::_bi::list_av_2<A1, A2>::type> boost::bind(F, A1, A2) [with F = PrintAux<std::vector<int, std::allocator<int> >, 1>, A1 = boost::arg<2>, A2 = std::basic_ostream<char, std::char_traits<char> ]' E:/Program Files/Dev-Cpp/include/boost/bind.hpp: At global scope: E:/Program Files/Dev-Cpp/include/boost/bind.hpp: In instantiation of `boost::_bi::result_traits<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1> ': E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:15: instantiated from `boost::_bi::bind_t<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1>, boost::_bi::list2<boost::arg<2>, boost::_bi::value<std::basic_ostream<char, std::char_traits<char> > > > >' Print.hpp:19: instantiated from `std::ostream& PrintAux<Container, i>::operator()(const Container&, std::ostream&) const [with Container = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > , unsigned int i = 2]' Print.hpp:62: instantiated from `std::ostream& Print(const T&, std::ostream&) [with T = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > ]' Print.cpp:30: instantiated from here E:/Program Files/Dev-Cpp/include/boost/bind.hpp:62: error: no type named ` result_type' in `struct PrintAux<std::vector<int, std::allocator<int> >, 1>'
E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp: In instantiation of `boost::_bi::bind_t<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1>, boost::_bi::list2<boost::arg<2>, boost::_bi::value<std::basic_ostream<char, std::char_traits<char> > > > >': Print.hpp:19: instantiated from `std::ostream& PrintAux<Container, i>::operator()(const Container&, std::ostream&) const [with Container = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> >
, unsigned int i = 2]' Print.hpp:62: instantiated from `std::ostream& Print(const T&, std::ostream&) [with T = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > ]'
Print.cpp:30: instantiated from here E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:15: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1> >' E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:18: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1> >' E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:24: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1> >' E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:30: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1> >' E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:30: confused by earlier errors, bailing out make.exe: *** [Print.o] Error 1 Execution terminated ___________________________________________________________ 24 FIFA World Cup tickets to be won with Yahoo! Mail http://uk.mail.yahoo.com
Hossein Haeri wrote:
Hi Steve.
I get it (on VC++2003) as the problem being a lack of return_type typedefs.
Doesn't work for GCC 3.3.1 either! :(
[...]
for_each(c.begin(), c.end(), bind(newPrint, _2, out));
You've already been advised to use: for_each(c.begin(), c.end(), bind(newPrint, _1, ref(out))); Remember, for_each only passes one argument, you can't use _2 to select the non-existent second one, and your noncopyability problem is solved by using boost::ref. You even asked "is there an equivalent to boost::ref" in your original post. Yes there is, it's called boost::ref. :-)
Hi Peter,
for_each(c.begin(), c.end(), bind(newPrint, _1, ref(out)));
Doesn't work either! The error file GCC (3.3.1) gives me is in the P.S. Is GGC right? And, BTW, thanks for letting me know about ref()! :) TIA, --Hossein P.S. Compiler: Default compiler Building Makefile: "E:\My Documents\My Programmes\Tests\Aarash\Makefile.win" Executing make... make.exe -f "E:\My Documents\My Programmes\Tests\Aarash\Makefile.win" all g++.exe -c Print.cpp -o Print.o -I"E:/Program Files/Dev-Cpp/include/c++/3.3.1" -I"E:/Program Files/Dev-Cpp/include/c++/3.3.1/mingw32" -I"E:/Program Files/Dev-Cpp/include/c++/3.3.1/backward" -I"E:/Program Files/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"E:/Program Files/Dev-Cpp/include" E:/Program Files/Dev-Cpp/include/boost/bind.hpp: In instantiation of `boost::_bi::result_traits<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1>
': E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:15: instantiated from `boost::_bi::bind_t<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1>, boost::_bi::list2<boost::arg<1>, boost::reference_wrapper<std::basic_ostream<char, std::char_traits<char> > > > >' E:/Program Files/Dev-Cpp/include/boost/bind.hpp:1306: instantiated from `boost::_bi::bind_t<boost::_bi::unspecified, F, typename boost::_bi::list_av_2<A1, A2>::type> boost::bind(F, A1, A2) [with F = PrintAux<std::vector<int, std::allocator<int> >, 1>, A1 = boost::arg<1>, A2 = boost::reference_wrapper<std::basic_ostream<char, std::char_traits<char> > >]' Print.hpp:19: instantiated from `std::ostream& PrintAux<Container, i>::operator()(const Container&, std::ostream&) const [with Container = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> >
, unsigned int i = 2]' Print.hpp:62: instantiated from `std::ostream& Print(const T&, std::ostream&) [with T = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > ]' Print.cpp:30: instantiated from here E:/Program Files/Dev-Cpp/include/boost/bind.hpp:62: error: no type named ` result_type' in `struct PrintAux<std::vector<int, std::allocator<int> >, 1>' E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp: In instantiation of `boost::_bi::bind_t<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1>, boost::_bi::list2<boost::arg<1>, boost::reference_wrapper<std::basic_ostream<char, std::char_traits<char> > > > >': E:/Program Files/Dev-Cpp/include/boost/bind.hpp:1306: instantiated from `boost::_bi::bind_t<boost::_bi::unspecified, F, typename boost::_bi::list_av_2<A1, A2>::type> boost::bind(F, A1, A2) [with F = PrintAux<std::vector<int, std::allocator<int> >, 1>, A1 = boost::arg<1>, A2 = boost::reference_wrapper<std::basic_ostream<char, std::char_traits<char> > >]' Print.hpp:19: instantiated from `std::ostream& PrintAux<Container, i>::operator()(const Container&, std::ostream&) const [with Container = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > , unsigned int i = 2]' Print.hpp:62: instantiated from `std::ostream& Print(const T&, std::ostream&) [with T = std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > ]' Print.cpp:30: instantiated from here E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:15: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1> >'
E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:18: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1> >' E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:24: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1> >' E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:30: error: no type named `type' in `struct boost::_bi::result_traits<boost::_bi::unspecified, PrintAux<std::vector<int, std::allocator<int> >, 1> >' E:/Program Files/Dev-Cpp/include/boost/bind/bind_template.hpp:30: confused by earlier errors, bailing out make.exe: *** [Print.o] Error 1 Execution terminated Send instant messages to your online friends http://uk.messenger.yahoo.com
Hossein Haeri wrote:
Hi Peter,
for_each(c.begin(), c.end(), bind(newPrint, _1, ref(out)));
Doesn't work either! The error file GCC (3.3.1) gives me is in the P.S. Is GGC right?
And, BTW, thanks for letting me know about ref()! :)
[...]
E:/Program Files/Dev-Cpp/include/boost/bind.hpp:62: error: no type named ` result_type' in `struct PrintAux<std::vector<int, std::allocator<int> >, 1>'
You either need a result_type typedef in PrintAux, or for_each(c.begin(), c.end(), bind<void>(newPrint, _1, ref(out)));
Hi Peter.
You either need a result_type typedef in PrintAux, or
for_each(c.begin(), c.end(), bind<void>(newPrint, _1, ref(out)));
Yup! Got it! :) Thanks! :) TTFN, --Hossein ___________________________________________________________ Switch an email account to Yahoo! Mail, you could win FIFA World Cup tickets. http://uk.mail.yahoo.com
participants (4)
-
Hossein Haeri
-
Jeff Flinn
-
Peter Dimov
-
stevejay