Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T>
- class Test {
- public:
- T &operator[] (size_t i) {
- return t;
- }
- T t;
- };
- void foo() {
- Test<int> t;
- t[2];
- }
- ==========
- $ gcc error.cpp
- error.cpp:6: error: declaration of ‘operator[]’ as non-function
- error.cpp:6: error: expected ‘;’ before ‘(’ token
- error.cpp:9: error: expected ‘;’ before ‘T’
- error.cpp: In function ‘void foo()’:
- error.cpp:14: error: no match for ‘operator[]’ in ‘t[2]’
- $ clang error.cpp
- error.cpp:6:18: error: unknown type name 'size_t'
- T &operator[] (size_t i) {
- ^
- 1 diagnostic generated.
Add Comment
Please, Sign In to add comment