Skip to content

Instantly share code, notes, and snippets.

@outro56
Created February 2, 2019 16:56
Show Gist options
  • Save outro56/3308d886026b21c62a3c65fcbe099f06 to your computer and use it in GitHub Desktop.
Save outro56/3308d886026b21c62a3c65fcbe099f06 to your computer and use it in GitHub Desktop.
template<typename T, typename U>
using assign_expression = decltype(std::declval<T&>() = std::declval<U&>());
template<typename T, typename U>
constexpr bool is_assignable = is_detected<assign_expression, T, U>;
template<typename...>
using try_to_instantiate = void;
using disregard_this = void;
template<template<typename...> class Expression, typename Attempt, typename... Ts>
struct is_detected_impl : std::false_type{};
template<template<typename...> class Expression, typename... Ts>
struct is_detected_impl<Expression, try_to_instantiate<Expression<Ts...>>, Ts...> : std::true_type{};
template<template<typename...> class Expression, typename... Ts>
constexpr bool is_detected = is_detected_impl<Expression, disregard_this, Ts...>::value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment