C++ 如何显式编写数组引用返回类型?

C++ 如何显式编写数组引用返回类型?,c++,syntax,C++,Syntax,我想知道如何明确返回数组引用的函数的返回类型 typedef int const (Three_Const_Ints)[3]; Three_Const_Ints const & foo () { static int const values[] = { 0, 1, 2 }; return values; } int const (&)[3] bar () // Does not compile. What is the proper syntax? {

我想知道如何明确返回数组引用的函数的返回类型

typedef int const (Three_Const_Ints)[3];

Three_Const_Ints const & foo ()
{
    static int const values[] = { 0, 1, 2 };
    return values;
}

int const (&)[3] bar ()   // Does not compile. What is the proper syntax?
{
    static int const values[] = { 0, 1, 2 };
    return values;
}
是的,我可以使用
std::array
,但是我非常想知道这个语法。

它是这样的:

int常量(&bar())[3];
尝试以下操作

int const (& bar() )[3]
{
    static int const values[] = { 0, 1, 2 };
    return values;
}


要返回对数组的引用,请使用以下语法:

int const (& bar())[3];
int const (& bar())[3];