[ create a new paste ] login | about

Link: http://codepad.org/54uGSrFS    [ raw code | output | fork ]

C++, pasted on Aug 19:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <boost/type_traits.hpp>

template<typename ptr_t>
struct TData
{
    typedef typename boost::remove_extent<ptr_t>::type value_type;
    ptr_t data;

    value_type & operator [] ( size_t id ) { return data[id]; }
    operator ptr_t & () { return data; }
};

int main( int argc, char ** argv )
{
    TData<float[100][100]> t;   
    t[1][1] = 5;
    return 0;
}


Output:
1
2
3
In function 'int main(int, char**)':
Line 16: error: ambiguous overload for 'operator[]' in 't[1]'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: