2015-12-14 4 views
1

я получаю следующее сообщение об ошибке после генерации сообщения .cc и файлы заголовков с nedtool/omnet (4,6)сообщение поколения, ambigious перегрузка оператора <<

неоднозначной перегрузки для «оператора < <» (операнд типы 'станд :: ostream {ака станд :: basic_ostream}' и 'Const станд :: basic_string') CurrentNeighboursMessage_m.cc

Это класс сообщения: CurrentNeighboursMessage.msg

cplusplus {{ 
#include <vector> 
#include <string> 

typedef std::vector<std::string> StringVector; 
}} 

    class noncobject StringVector; 

    packet CurrentNeighboursMessage { 
     StringVector currentNeighbours; 
    } 

Соответствующий код ошибки в сгенерированном CurrentNeighboursMessage_m.cc:

ошибка в этой строке:

< < из * он;

// operator<< for std::vector<T> 
    template<typename T, typename A> 
    inline std::ostream& operator<<(std::ostream& out, const std::vector<T,A>& vec) 
    { 
     out.put('{'); 
     for(typename std::vector<T,A>::const_iterator it = vec.begin(); it != vec.end(); ++it) 
     { 
      if (it != vec.begin()) { 
       out.put(','); out.put(' '); 
      } 

      out << *it; 
     } 
     out.put('}'); 

     char buf[32]; 
     sprintf(buf, " (size=%u)", (unsigned int)vec.size()); 
     out.write(buf, strlen(buf)); 
     return out; 
    } 

Кто-нибудь знает решение?

ответ

0

нашел решение по адресу: https://groups.google.com/forum/#!msg/omnetpp/9Cw6F6ws_pc/isW42Rh0WG4J

либо не использовать или использовать определения типов это временное решение:

cplusplus {{ 
#include <vector> 
#include <string> 
//workaround 
typedef std::string MyString; 

inline std::ostream & operator << (std::ostream & os, const MyString & s) { 
     std::operator<<(os, s);   
     return os; 
} 
typedef std::vector<MyString> StringVector; 

}} 
class noncobject StringVector; 
packet CurrentNeighboursMessage { 
    StringVector currentNeighbours; 
} 
Смежные вопросы