I'm trying to use perfect forwarding on my custom vector class (to mimic the std::vector "emplace_back" in a sense) and to export it from the dll it is defined in.
repeated_ptr_field.hpp
template<typename TMessage> class RepeatedPtrField { private: std::vector<std::unique_ptr<TMessage>> v_; public: RepeatedPtrField(const RepeatedPtrField& other) = delete; RepeatedPtrField& operator=(const RepeatedPtrField& other) = delete; RepeatedPtrField(); // Some things... TMessage* Add() { // This one is ok so far v_.push_back(std::make_unique<TMessage>()); return v_.back().get(); } template <typename ...Args> TMessage* Add(Args&& ...args) { // This one is giving me headaches v_.push_back(std::make_unique<TMessage>(std::forward<Args>(args)...)); return v_.back().get(); } // Some other things... };
repeated_ptr_field.cpp
template __declspec(dllexport) Value* RepeatedPtrField<Value>::Add(double&&, Currency&&, long&&);
value.hpp
class Value : public Message { // Some things... public: // Both constructors defined in .cpp __declspec(dllexport) Value(); __declspec(dllexport) Value(double value, Currency ccy, long timestamp); // This is the constructor that should be used by the Add(args...) method. // Some other things... };
And I'm getting the compiler error: 'Value::Value': no overloaded function takes 3 arguments