template <size_t size> class Araye {
public:
typedef int (&array_ref)[size];
operator array_ref () { return araye; }
// ...
Or with identity
(thanks Johannes):
operator typename identity<int[size]>::type &() { return araye; }
With that your example works, but i'd prefer the following declaration instead:
Araye<3>::array_ref reference = araye;
There usually should be no need for this though as the subscripting operator should cover most needs:
int& operator[](size_t i) { return araye[i]; }
Note that if you are ok with limiting your class to being an aggregate, you could shorten your sample to the following instead:
template <size_t size> struct Araye {
int araye[size];
typedef int (&array_ref)[size];
operator array_ref () { return araye; }
};
Araye<3> araye = {1,2,3};
Araye<3>::array_ref reference = araye;