#include <algorithm>
#include <vector>
#include <array>
#include <iostream>
const struct in_op final
{
template<typename T>
struct impl
{
T const& x;
template<typename Container>
bool operator>(Container const& c) const
{
return std::find(std::begin(c), std::end(c), x) != std::end(c);
}
};
template<typename T>
friend auto operator<(T const &x, in_op) {
return impl<T>{x};
}
} in;
int main()
{
const std::array<int, 3> a{ 1, 2, 3 };
const std::vector<int> b{ 1, 2, 3 };
const std::initializer_list<int> c{ 5, 6, 7 };
std::cout << "5 in { 1, 2, 3 } = " << std::boolalpha << (5 <in> a) << '\n';
std::cout << "2 in { 1, 2, 3 } = " << std::boolalpha << (2 <in> b) << '\n';
std::cout << "7 in { 5, 6, 7 } = " << std::boolalpha << (7 <in> c) << '\n';
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFycmF5PgojaW5jbHVkZSA8aW9zdHJlYW0+Cgpjb25zdCBzdHJ1Y3QgaW5fb3AgZmluYWwKewoJdGVtcGxhdGU8dHlwZW5hbWUgVD4KCXN0cnVjdCBpbXBsCgl7CgkJVCBjb25zdCYgeDsKCgkJdGVtcGxhdGU8dHlwZW5hbWUgQ29udGFpbmVyPgoJCWJvb2wgb3BlcmF0b3I+KENvbnRhaW5lciBjb25zdCYgYykgY29uc3QKCQl7CgkJCXJldHVybiBzdGQ6OmZpbmQoc3RkOjpiZWdpbihjKSwgc3RkOjplbmQoYyksIHgpICE9IHN0ZDo6ZW5kKGMpOwoJCX0KCX07CgoJdGVtcGxhdGU8dHlwZW5hbWUgVD4KCWZyaWVuZCBhdXRvIG9wZXJhdG9yPChUIGNvbnN0ICZ4LCBpbl9vcCkgewoJCXJldHVybiBpbXBsPFQ+e3h9OwoJfQp9IGluOwoKaW50IG1haW4oKQp7Cgljb25zdCBzdGQ6OmFycmF5PGludCwgMz4gICAgICAgICBheyAxLCAyLCAzIH07Cgljb25zdCBzdGQ6OnZlY3RvcjxpbnQ+ICAgICAgICAgICBieyAx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