/*
* Copyright (c) 2018 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#pragma once
#include
namespace detail {
template
struct class_of;
template
struct class_of {
using type = C;
};
template
using class_of_t = typename class_of::type;
template>
struct member_equals_fn_helper {
T ref;
Mem mem_fn;
bool operator()(const C& val) const {
return (std::mem_fn(mem_fn)(val) == ref);
}
bool operator()(C&& val) const {
return (std::mem_fn(mem_fn)(std::move(val)) == ref);
}
};
} // namespace detail
template
auto member_equals_fn(Mem mem, T ref) {
return detail::member_equals_fn_helper{std::move(ref), std::move(mem)};
}