如何缩短内部 class 私有的 return 类型中的嵌套命名空间?

How to shorten nested namespaces in a return type which is private to an inner class?

这个问题是关于在 .cpp 文件中 return 类型的方法中处理长嵌套的私有 class 命名空间。 previous questions on 避免在 cpp 文件中使用长名称和嵌套命名空间,但它们似乎没有涵盖我的用例。

我有一个私有 nested class,在 header .h 文件中有一个特定于 class 的私有类型,如下所示:

class outer {
    class inner {
        typedef map<int, map<int, int>> footype;
    private:
        footype manipulate_foos(footype f1, footype f2);
    }
}

.cpp 文件中定义方法时,如果我不使用指向 return 类型的名称空间的完整路径,编译器会报错,即使名称空间是在参数类型中推断出来的。所以我必须写一些类似

的东西
outer::inner::footype outer::inner::manipulate_foos(footype f1, footypte f2) {
    // body
}

在我的例子中,这需要将 return 类型和方法名称拆分成多行,而且难以阅读。

问题

当 return 类型对内部 class 私有时,是否有任何方法可以省略该类型中的命名空间?


备注

这似乎有效:

auto outer::inner::manipulate_foos(footype f1, footype f2) -> footype { ... }