// PR c++/96926 // { dg-do compile { target c++11 } } namespace std { template struct integral_constant { static constexpr _Tp value = __v; typedef integral_constant<_Tp, __v> type; }; template constexpr _Tp integral_constant<_Tp, __v>::value; typedef integral_constant true_type; typedef integral_constant false_type; template using bool_constant = integral_constant; template struct conditional; template struct __and_; template<> struct __and_<> : public true_type { }; template struct __and_<_B1> : public _B1 { }; template struct __and_<_B1, _B2> : public conditional<_B1::value, _B2, _B1>::type { }; template struct __and_<_B1, _B2, _B3, _Bn...> : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type { }; template struct is_constructible : public bool_constant<__is_constructible(_Tp, _Args...)> { }; template struct enable_if { }; template struct enable_if { typedef _Tp type; }; template using __enable_if_t = typename enable_if<_Cond, _Tp>::type; template struct conditional { typedef _Iftrue type; }; template struct conditional { typedef _Iffalse type; }; template struct _TupleConstraints { template static constexpr bool __is_implicitly_constructible() { // is_constructible is incomplete here, but only when // it is also instantiated in __is_explicitly_constructible return __and_..., true_type >::value; } template static constexpr bool __is_explicitly_constructible() { #if FIX return false; #else return __and_..., false_type >::value; #endif } }; template class tuple { template using _TCC = _TupleConstraints<_Cond, _Elements...>; template using _ImplicitCtor = __enable_if_t< _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(), bool>; template using _ExplicitCtor = __enable_if_t< _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(), bool>; public: template = true> constexpr tuple(const _Elements&... __elements) { } template = false> explicit constexpr tuple(const _Elements&... __elements) { } }; } // first example template struct SomeQuery { SessionT& session_; SomeQuery(SessionT& session) : session_(session) {} }; template struct Handler { std::tuple> queries_; Handler(SessionT& session) : queries_(session) {} }; struct Session { Handler handler_; Session() : handler_{*this} {} }; int main() { Session session; } static_assert(std::is_constructible, const SomeQuery&>::value, ""); // second example template class DependsOnT { public: DependsOnT(T&) {} }; class Test { public: Test() : test_{*this} {} private: std::tuple> test_; }; static_assert(std::is_constructible, const DependsOnT&>::value, "");