#include <iostream>
#include <string>
#include <vector>
#include <set>
namespace FileSystem {
struct Info {
std:: string path;
} ;
}
#define STATIC_ASSERT(cond, msg) \
typedef char static_assert_##msg[2*(!!cond)-1];
#define CREATE_MEMBER_DETECTOR(member) \
template<typename T> \
class detector_of_##member { \
private: \
typedef char Yes[1]; \
typedef char No[2]; \
struct Base {char member;}; \
struct Derived: T, Base {}; \
\
template<typename PointerToMember, PointerToMember> \
struct Check {}; \
\
template<typename D> \
static Yes& result(...); \
template<typename D> \
static No& result(Check<char Base::*, &D::member>*); \
\
public: \
enum {value = sizeof(result<Derived>(0)) == 1}; \
};
CREATE_MEMBER_DETECTOR( push_back)
CREATE_MEMBER_DETECTOR( path)
typedef std:: set < FileSystem:: Info > X;
typedef std:: vector < std:: string > Y;
typedef std:: vector < FileSystem:: Info > Z;
int main( )
{
STATIC_ASSERT( detector_of_push_back< X> :: value , no_push_back) ;
STATIC_ASSERT( detector_of_push_back< Y> :: value , no_push_back) ;
STATIC_ASSERT( detector_of_path< Y:: value_type > :: value , no_path) ;
STATIC_ASSERT( detector_of_path< Z:: value_type > :: value , no_path) ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c2V0PgoKbmFtZXNwYWNlIEZpbGVTeXN0ZW0gewogICAgc3RydWN0IEluZm8gewogICAgICAgIHN0ZDo6c3RyaW5nIHBhdGg7CiAgICB9Owp9CgojZGVmaW5lIFNUQVRJQ19BU1NFUlQoY29uZCwgbXNnKSBcCnR5cGVkZWYgY2hhciBzdGF0aWNfYXNzZXJ0XyMjbXNnWzIqKCEhY29uZCktMV07CgojZGVmaW5lIENSRUFURV9NRU1CRVJfREVURUNUT1IobWVtYmVyKSBcCnRlbXBsYXRlPHR5cGVuYW1lIFQ+IFwKY2xhc3MgZGV0ZWN0b3Jfb2ZfIyNtZW1iZXIgeyBcCnByaXZhdGU6IFwKICAgIHR5cGVkZW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V90eXBlPjo6dmFsdWUsIG5vX3BhdGgpOwogICAgU1RBVElDX0FTU0VSVChkZXRlY3Rvcl9vZl9wYXRoPFo6OnZhbHVlX3R5cGU+Ojp2YWx1ZSwgbm9fcGF0aCk7Cn0=
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13:46: error: size of array ‘static_assert_no_push_back’ is negative
typedef char static_assert_##msg[2*(!!cond)-1];
^
prog.cpp:44:5: note: in expansion of macro ‘STATIC_ASSERT’
STATIC_ASSERT(detector_of_push_back<X>::value, no_push_back);
^
prog.cpp:13:46: error: size of array ‘static_assert_no_path’ is negative
typedef char static_assert_##msg[2*(!!cond)-1];
^
prog.cpp:46:5: note: in expansion of macro ‘STATIC_ASSERT’
STATIC_ASSERT(detector_of_path<Y::value_type>::value, no_path);
^
stdout