Skip to content

Instantly share code, notes, and snippets.

@yuxuanchen1997
Last active July 10, 2024 00:07
Show Gist options
  • Save yuxuanchen1997/576dce964666f0f8713fccacf5847138 to your computer and use it in GitHub Desktop.
Save yuxuanchen1997/576dce964666f0f8713fccacf5847138 to your computer and use it in GitHub Desktop.
clang++ -std=c++20 Crash.cpp
template <bool v>
struct BC {
static constexpr bool value = v;
};
template <typename B> struct __and_ : B {
static constexpr bool value = true;
};
template <typename A>
using _Requires = __and_<A>::value;
template <typename _Tp, typename _Args>
struct __is_constructible_impl : BC<__is_constructible(_Tp, _Args)> {};
template <typename _Tp>
struct optional {
template <typename _Up, _Requires<__is_constructible_impl<_Tp, _Up>> = true>
optional(_Up) {}
};
struct MO {};
struct S : MO {};
struct TB {
TB(optional<S>) {}
};
class Try : public TB, MO {
using TB::TB;
};
template <typename T>
struct MQB;
template <>
struct MQB<Try> {
static_assert(__is_constructible_impl<Try, Try>::value);
};
void foo() {
MQB<Try> m;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment