Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid template arguments on map std::map< std::string, Stock*> &stocks

I have the declaration (or similar)

std::map< std::string, Stock*> &stocks;

throughout my code. Eclipse does not like this and produces a "Invalid template arguments" error.

Stock is declared as:

class Stock {

 public:
    Stock(std::string, qbbo::Financial_status_indicator, qbbo::Security_class,
          qbbo::Current_trading_state,
          qbbo::Market_category, qbbo::Reg_sho_action);
    ~Stock();
    void setFinancialStatusIndicator(qbbo::Financial_status_indicator financialStatusIndicator);
    void setSecurityClass(qbbo::Security_class securityClass);
    void setCurrentTradingState(qbbo::Current_trading_state tradingState);
    void setMarketCategory(qbbo::Market_category marketCategory);
    void setREGShoAction(qbbo::Reg_sho_action regSHOAction);
    bool isStockTrading();

  private:
    enum StockState {
      STOCK_STATE_OK, STOCK_STATE_UNKNOWN, STOCK_STATE_UNEXPECTED_CHARACTERISTIC
    };

    std::string name;
    int inventory;
    StockState currentState;

    // Expected values initialised in constructor
    qbbo::Financial_status_indicator expectedFinancialStatusIndicator;
    qbbo::Security_class expectedSecurityClass;
    qbbo::Current_trading_state expectedCurrentTradingState;
    qbbo::Market_category expectedMarketCategory;
    qbbo::Reg_sho_action expectedRegSHOAction;

    // Actual values as set by messages
    qbbo::Financial_status_indicator financialStatusIndicator;
    qbbo::Security_class securityClass;
    qbbo::Current_trading_state currentTradingState;
    qbbo::Market_category marketCategory;
    qbbo::Reg_sho_action regSHOAction;

    void nextState();
};

I cannot see whats invalid about this declaration and it compiles fine. Is there something I'm missing and Eclipse is catching?

Short Self Contained Correct Example

#include <string>
#include <map>

#include "stock.h"

int main() {
  std::map<std::string, Stock*> stocks;
}
like image 275
Jonathan Evans Avatar asked Jun 06 '12 10:06

Jonathan Evans


1 Answers

Turned out to be an eclipse error. Creating a new project and re-following the steps Eclipse CDT C++11/C++0x support sorted it.

like image 60
Jonathan Evans Avatar answered Oct 23 '22 01:10

Jonathan Evans