Visual C ++ 2010 внутренняя ошибка с boost :: multi_index? - PullRequest
1 голос
/ 15 декабря 2010

Я использую boost :: multi_index с Visual Studio 2010, и, похоже, происходит сбой при использовании методов boost :: const_mem_fun и виртуального класса:

class Node
{
public:
    virtual const std::string& getValue() const {return m_strValue;}

protected:
    std::string m_strValue;

private:
    struct byValue{};
    typedef boost::multi_index_container<
     boost::shared_ptr<Node>,
     boost::multi_index::indexed_by<
      boost::multi_index::random_access<>,
      boost::multi_index::ordered_non_unique<
       boost::multi_index::tag<byValue>,
       boost::multi_index::const_mem_fun<Node, const std::string& , &Node::getValue>
      >
     >
    > NodeList;
};

при компиляции, визуальный сбой с этимтип сообщения:

fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'msc1.cpp', line 1420)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1> Please choose the Technical Support command on the Visual C++ 
1> Help menu, or open the Technical Support help file for more information

, но если Node :: getValue не является виртуальным, компиляция в порядке.есть ли способ обойти это?

Ответы [ 2 ]

1 голос
/ 15 декабря 2010

Эту ошибку компилятора можно обойти, используя определяемый пользователем ключевой экстрактор :

class Node
{
public:
    virtual const std::string& getValue() const {return m_strValue;}

protected:
    std::string m_strValue;

private:
    struct KeyExtractor
    {
      typedef std::string result_type;

      const result_type& operator()(const boost::shared_ptr<Node>& p) const
      {
          return p->getValue();
      }        
    };

    struct byValue{};

    typedef boost::multi_index_container<
     boost::shared_ptr<Node>,
     boost::multi_index::indexed_by<
      boost::multi_index::random_access<>,
      boost::multi_index::ordered_non_unique<
       boost::multi_index::tag<byValue>,
       KeyExtractor
      >
     >
    > NodeList;
};
0 голосов
/ 15 декабря 2010

Сообщить об ошибке в Microsoft.

Независимо от того, насколько странным является код, компилятор не должен падать.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...