Visual Studio: Error C2679

I am making a function that holds a vector of references. When I try to cout the references: int works fine, but if I output std::string I get the error 'error C2679: binary '<<': no operator found which takes a right-hand operand of type 'std::reference_wrapper<UnknownObject>' (or there is no acceptable conversion)'

edit: and when I remove the code to add and print the screen(but keep the int), I get:error LNK2001: unresolved external symbol "public: static class std::vector<class std::reference_wrapper<int>,class std::allocator<class std::reference_wrapper<int> > > ObjectList<int>::_objectList" (?_objectList@?$ObjectList@H@@2V?$vector@V?$reference_wrapper@H@std@@V?$allocator@V?$reference_wrapper@H@std@@@2@@std@@A)

The full code for the class is here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pragma once
#include <cstdint>
#include <vector>
#include <utility>
#include <string>

template <class UnknownObject> class ObjectList
{
public:
	static void Add(UnknownObject& objectToAdd);

	static std::vector <std::reference_wrapper<UnknownObject>> _objectList;
};

template<class UnknownObject>
inline void ObjectList<UnknownObject>::Add(UnknownObject& objectToAdd)
{
	_objectList.push_back(objectToAdd);
}
Last edited on
Topic archived. No new replies allowed.