我能以某种方式不写出完整的合格返回类型名称吗?

Nik*_*s R 2 c++ code-duplication clang visual-c++ c++11

我有以下嵌套类的情况:

class PS_OcTree {
public:
  // stuff ...

private:
  struct subdiv_criteria : public octree_type::subdiv_criteria {
    PS_OcTree* tree;
    subdiv_criteria(PS_OcTree* _tree) : tree(_tree) { }
    virtual Element elementInfo(unsigned int const& elem, node const* n) override;
  };
};
Run Code Online (Sandbox Code Playgroud)

为了在.cpp文件中实现这个方法,我写了

PS_OcTree::subdiv_criteria::Element
PS_OcTree::subdiv_criteria::elementInfo(
  unsigned int const& poly_index, node const* n)
{
    // implementation goes here
}
Run Code Online (Sandbox Code Playgroud)

我写这个方法的全名很好,但是我真的还需要写回返类型的全名吗?在参数括号和函数体内,我可以访问subdiv_criteria类的名称,但这似乎不适用于返回类型.

我想写一些类似的东西

Element PS_OcTree::subdiv_criteria::elementInfo(
  unsigned int const& poly_index, node const* n)
{
    // implementation goes here
}

// or

auto PS_OcTree::subdiv_criteria::elementInfo(
  unsigned int const& poly_index, node const* n)
{
    // implementation goes here
}
Run Code Online (Sandbox Code Playgroud)

至少有些东西不需要我PS_OcTree::subdiv_criteria在返回类型中重复.我可以使用C++ 11中的某些东西吗?它应该与MSVC 2015和Clang 5一起使用.

T.C*_*.C. 7

类范围查找适用于declarator-id之后的任何内容(即定义的函数的名称,即PS_OcTree::subdiv_criteria::elementInfo),包括尾随返回类型.因此,

auto PS_OcTree::subdiv_criteria::elementInfo(
  unsigned int const& poly_index, node const* n) -> Element 
{
}
Run Code Online (Sandbox Code Playgroud)