Re: compile time dependencies
Zeppe wrote:
yurec wrote:
Hi
I can't compile
//#include <boost/function.hpp>
class boost::function;
UIStl * LoadStlFromAnotherProject(const CString & i_project_name,
boost::function<bool (MSAXReader &,UIObject *)> i_func_compare);
1. Parameter and return types need only to be forward-declared.
(Herb Sutter , Exceptional C++: 47 Engineering Puzzles, Programming
Problems, and Solutions, Item 26)
Can anybody tell me correct syntax?
You have to include the header, because you are instantiating a template
class.
It's not necessary
<std>
14.7.3/10
A template-id that names a class template explicit specialization that
has been declared but not defined can be used exactly like the names of
other incompletely-defined classes (3.9). [Example:
template<class T> class X; // X is a class template
template<> class X<int>;
X<int>* p; // OK: pointer to declared class X<int>
X<int> x; // error: object of incomplete class X<int>
end example]
</std>
here is how what the op want,
anyway, I don't suggest this :-)
<code>
namespace boost {
template <class, class>
class function;
}
#include <boost/function.hpp>
void invoke(boost::function<int(int)>& f) {
f(10);
}
#include <iostream>
int f(int i) { std::cout << i << std::endl; return i; }
int main() {
boost::function<int(int)> fobj(f);
invoke(fobj);
}
</code>