mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
Move unused to util
This commit is contained in:
parent
7accbdf41c
commit
eb8528c90e
@ -20,7 +20,8 @@
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "continuable/continuable.hpp"
|
#include <continuable/continuable.hpp>
|
||||||
|
#include <continuable/detail/util.hpp>
|
||||||
|
|
||||||
using cti::detail::util::unused;
|
using cti::detail::util::unused;
|
||||||
|
|
||||||
@ -40,7 +41,9 @@ void creating_continuables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ResultSet {};
|
struct ResultSet {};
|
||||||
template <typename... Args> void mysql_handle_async_query(Args&&...) {}
|
template <typename... Args>
|
||||||
|
void mysql_handle_async_query(Args&&...) {
|
||||||
|
}
|
||||||
|
|
||||||
auto mysql_query(std::string query) {
|
auto mysql_query(std::string query) {
|
||||||
return cti::make_continuable<ResultSet>([query = std::move(query)](
|
return cti::make_continuable<ResultSet>([query = std::move(query)](
|
||||||
|
|||||||
@ -45,7 +45,7 @@ template <typename C> void assert_async_completion(C&& continuable) {
|
|||||||
*called = true;
|
*called = true;
|
||||||
|
|
||||||
// Workaround for our known GCC bug.
|
// Workaround for our known GCC bug.
|
||||||
traits::unused(std::forward<decltype(args)>(args)...);
|
util::unused(std::forward<decltype(args)>(args)...);
|
||||||
});
|
});
|
||||||
ASSERT_TRUE(*called);
|
ASSERT_TRUE(*called);
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ template <typename C> void assert_async_completion(C&& continuable) {
|
|||||||
template <typename C> void assert_async_never_completed(C&& continuable) {
|
template <typename C> void assert_async_never_completed(C&& continuable) {
|
||||||
std::forward<C>(continuable).then([](auto&&... args) {
|
std::forward<C>(continuable).then([](auto&&... args) {
|
||||||
// Workaround for our known GCC bug.
|
// Workaround for our known GCC bug.
|
||||||
traits::unused(std::forward<decltype(args)>(args)...);
|
util::unused(std::forward<decltype(args)>(args)...);
|
||||||
|
|
||||||
FAIL();
|
FAIL();
|
||||||
});
|
});
|
||||||
@ -111,7 +111,7 @@ void assert_async_types(C&& continuable, traits::identity<Args...> expected) {
|
|||||||
assert_async_validation(
|
assert_async_validation(
|
||||||
std::forward<C>(continuable), [&](auto... actualPack) {
|
std::forward<C>(continuable), [&](auto... actualPack) {
|
||||||
auto actual = traits::identity<decltype(actualPack)...>{};
|
auto actual = traits::identity<decltype(actualPack)...>{};
|
||||||
traits::unused(expected, actual,
|
util::unused(expected, actual,
|
||||||
std::forward<decltype(actualPack)>(actualPack)...);
|
std::forward<decltype(actualPack)>(actualPack)...);
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
|
|||||||
@ -159,18 +159,6 @@ constexpr auto get(identity<T...>) noexcept {
|
|||||||
return identity_of<at_t<I, T...>>();
|
return identity_of<at_t<I, T...>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper to trick compilers about that a parameter pack is used
|
|
||||||
template <typename... T>
|
|
||||||
void unused(T&&... args) {
|
|
||||||
auto use = [](auto&& type) mutable {
|
|
||||||
(void)type;
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
auto deduce = {0, use(std::forward<decltype(args)>(args))...};
|
|
||||||
(void)deduce;
|
|
||||||
(void)use;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
// Equivalent to C++17's std::void_t which targets a bug in GCC,
|
// Equivalent to C++17's std::void_t which targets a bug in GCC,
|
||||||
// that prevents correct SFINAE behavior.
|
// that prevents correct SFINAE behavior.
|
||||||
|
|||||||
@ -43,6 +43,18 @@ namespace cti {
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
/// Utility namespace which provides useful meta-programming support
|
/// Utility namespace which provides useful meta-programming support
|
||||||
namespace util {
|
namespace util {
|
||||||
|
/// Helper to trick compilers about that a parameter pack is used
|
||||||
|
template <typename... T>
|
||||||
|
void unused(T&&... args) {
|
||||||
|
auto use = [](auto&& type) mutable {
|
||||||
|
(void)type;
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
auto deduce = {0, use(std::forward<decltype(args)>(args))...};
|
||||||
|
(void)deduce;
|
||||||
|
(void)use;
|
||||||
|
}
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <typename T, typename Args, typename = traits::void_t<>>
|
template <typename T, typename Args, typename = traits::void_t<>>
|
||||||
struct is_invokable_impl : std::common_type<std::false_type> {};
|
struct is_invokable_impl : std::common_type<std::false_type> {};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user