Eclipse IDE is throwing me an error on the following line that "method 'get' could not be resolved". The exact error message is
Method 'get' could not be resolved, Location: line xxx, Type: Semantic Error
The error line:
const TagValue* tagValue = ((*mktDataOptions)[i]).get();
What is going wrong here? This code was given to me as an API so presumably others have used it before. Similar errors appear about 8 other times in the code I was given and I have trouble believing it was coded wrong the same way 8 separate times.
Questions
Can someone parse this line for me and explain exactly what it is trying to do?
Why is my Eclipse throwing an error for all these instances and how can it be fixed?
Relevant Code
This line exists in the function:
void EClient::reqMktData(TickerId tickerId, const Contract& contract,
const std::string& genericTicks, bool snapshot, const TagValueListSPtr& mktDataOptions)
...
if( m_serverVersion >= MIN_SERVER_VER_LINKING) {
std::string mktDataOptionsStr("");
const int mktDataOptionsCount = mktDataOptions.get() ? mktDataOptions->size() : 0;
...
const TagValue* tagValue = ((*mktDataOptions)[i]).get();
Where "TagValueListSPtr" is defined in a header as
struct TagValue
{
TagValue() {}
TagValue(const std::string& p_tag, const std::string& p_value)
: tag(p_tag), value(p_value)
{}
std::string tag;
std::string value;
};
typedef shared_ptr<TagValue> TagValueSPtr;
typedef std::vector<TagValueSPtr> TagValueList;
typedef shared_ptr<TagValueList> TagValueListSPtr;
And "shared_ptr" is defined as
template<typename X> class shared_ptr {
public:
typedef shared_ptr_defs::Use Use;
template<typename Y> friend class shared_ptr;
explicit shared_ptr(X* ptr = 0) : ptr_(ptr) {}
~shared_ptr() { if (use_.only()) delete ptr_; }
template<typename Y>
shared_ptr(const shared_ptr<Y>& other)
: ptr_(other.ptr_),
use_(other.use_)
{}
shared_ptr& operator=(const shared_ptr& other) {
if ( &use_ == &other.use_ ) { return *this; }
if ( use_.only() ) { delete ptr_; }
use_ = other.use_;
ptr_ = other.ptr_;
return *this;
}
X& operator*() const { return *ptr_; }
X* operator->() const { return ptr_; }
X* get() const { return ptr_; }
bool only() const { return use_.only(); }
void reset(X* ptr = 0) {
if ( use_.only() ) { delete ptr_; }
ptr_ = ptr;
use_ = Use();
}
private:
X *ptr_;
Use use_;
};