You can't forward declare nested class, see this answer.
However, if your class is not nested, you can do it like this:
// inside library_fwd.hpp:
namespace library {
namespace whatever {
template <class T>
class Something;
typedef Something<int> IntSomething;
} // namespace whatever
} // namespace library
and:
// inside foo.cpp
#include "library_fwd.hpp"
void foo(const library::whatever::IntSomething&);
Your problem with std::vector example is about conflicting declarations. See std::vector. Fix:
namespace std {
template <class T>
class allocator;
template <typename T, class Allocator>
class vector;
}
typedef std::vector<int, std::allocator<int>> Buffer;
void foo(const Buffer &);
#include <vector> // now ok
int main () {
foo (Buffer ());
}
PS example of some std lib forward declaration: http://en.cppreference.com/w/cpp/header/iosfwd