| 1 |
#include <string> |
| 2 |
|
| 3 |
//classes |
| 4 |
template <typename Type> |
| 5 |
struct String |
| 6 |
{ |
| 7 |
struct iterator |
| 8 |
{ |
| 9 |
using StringType_iterator = int; |
| 10 |
friend bool operator==<>(iterator const &lhs, iterator const &rhs); |
| 11 |
|
| 12 |
std::string::iterator d_iter; |
| 13 |
}; |
| 14 |
iterator begin() |
| 15 |
{ |
| 16 |
return iterator{}; |
| 17 |
} |
| 18 |
}; |
| 19 |
|
| 20 |
template <typename Type> |
| 21 |
struct Container |
| 22 |
{ |
| 23 |
struct iterator |
| 24 |
{ |
| 25 |
using ContainerType_iterator = int; |
| 26 |
friend bool operator==<>(iterator const &lhs, iterator const &rhs); |
| 27 |
|
| 28 |
int *d_ptr; |
| 29 |
}; |
| 30 |
iterator begin() |
| 31 |
{ |
| 32 |
return iterator{}; |
| 33 |
} |
| 34 |
}; |
| 35 |
//= |
| 36 |
|
| 37 |
//code |
| 38 |
template <typename Type, Type::StringType_iterator = 0> |
| 39 |
inline bool operator==(Type const &lhs, Type const &rhs) |
| 40 |
{ |
| 41 |
return lhs.d_iter == rhs.d_iter; |
| 42 |
} |
| 43 |
|
| 44 |
template <typename Type, Type::ContainerType_iterator = 0> |
| 45 |
inline bool operator==(Type const &lhs, Type const &rhs) |
| 46 |
{ |
| 47 |
return lhs.d_ptr == rhs.d_ptr; |
| 48 |
} |
| 49 |
//= |
| 50 |
|
| 51 |
//main |
| 52 |
int main() |
| 53 |
{ |
| 54 |
String<int> str; |
| 55 |
Container<int> cnt; |
| 56 |
return str.begin() == str.begin() and cnt.begin() == cnt.begin(); |
| 57 |
} |
| 58 |
//= |