#include <iostream>
template <typename T>
class has_size {
private:
typedef char Yes;
typedef Yes No[2];
template <typename U, U> struct really_has;
template<typename C> static Yes& Test(really_has <size_t (C::*)() const, &C::size>*);
template<typename> static No& Test(...);
public:
static bool const value = sizeof(Test<T>(0)) == sizeof(Yes);
};
struct NoSize {};
struct Sized { size_t size() const { return 0; } };
struct BadlySized { int size() { return 0; } };
struct MultiSized { size_t size() const { return 0; } int size(int) { return 0; } };
int main() {
std::cout << "NoSize: " << has_size<NoSize>::value << "\n";
std::cout << "Sized: " << has_size<Sized>::value << "\n";
std::cout << "BadlySized: " << has_size<BadlySized>::value << "\n";
std::cout << "MultiSized: " << has_size<MultiSized>::value << "\n";
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+CmNsYXNzIGhhc19zaXplIHsKcHJpdmF0ZToKICB0eXBlZGVmIGNoYXIgWWVzOwogIHR5cGVkZWYgWWVzIE5vWzJdOwoKICB0ZW1wbGF0ZSA8dHlwZW5hbWUgVSwgVT4gc3RydWN0IHJlYWxseV9oYXM7CgogIHRlbXBsYXRlPHR5cGVuYW1lIEM+IHN0YXRpYyBZZXMmIFRlc3QocmVhbGx5X2hhcyA8c2l6ZV90IChDOjoqKSgpIGNvbnN0LCAmQzo6c2l6ZT4qKTsKICB0ZW1wbGF0ZTx0eXBlbmFtZT4gc3RhdGljIE5vJiBUZXN0KC4uLik7CgpwdWJsaWM6CiAgICBzdGF0aWMgYm9vbCBjb25zdCB2YWx1ZSA9IHNpemVvZihUZXN0PFQ+KDApKSA9PSBzaXplb2YoWWVzKTsKfTsKCnN0cnVjdCBOb1NpemUge307CgpzdHJ1Y3QgU2l6ZWQgeyBzaXplX3Qgc2l6ZSgpIGNvbnN0IHsgcmV0dXJuIDA7IH0gfTsKCnN0cnVjdCBCYWRseVNpemVkIHsgaW50IHNpemUoKSB7IHJldHVybiAwOyB9IH07CgpzdHJ1Y3QgTXVsdGlTaXplZCB7IHNpemVfdC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