1c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//===----------------------------------------------------------------------===// 2c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// 3c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// The LLVM Compiler Infrastructure 4c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// 5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open 6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details. 7c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// 8c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//===----------------------------------------------------------------------===// 9c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 10c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// type_traits 11c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 12c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// template <class T, class... Args> 13c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// struct is_constructible; 14c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 15c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant#include <type_traits> 16c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 17c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantstruct A 18c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant{ 19c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant explicit A(int); 20c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant A(int, double); 21933afa9761c1c1f916161278a99284d50a594939Marshall Clow#if __has_feature(cxx_access_control_sfinae) 226063ec176d5056683d6ddd310c2e3a8f1c7e1b46Howard Hinnantprivate: 23933afa9761c1c1f916161278a99284d50a594939Marshall Clow#endif 246063ec176d5056683d6ddd310c2e3a8f1c7e1b46Howard Hinnant A(char); 25c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant}; 26c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 27933afa9761c1c1f916161278a99284d50a594939Marshall Clowtemplate <class T> 28933afa9761c1c1f916161278a99284d50a594939Marshall Clowvoid test_is_constructible() 29933afa9761c1c1f916161278a99284d50a594939Marshall Clow{ 30933afa9761c1c1f916161278a99284d50a594939Marshall Clow static_assert( (std::is_constructible<T>::value), ""); 31933afa9761c1c1f916161278a99284d50a594939Marshall Clow} 32933afa9761c1c1f916161278a99284d50a594939Marshall Clow 33933afa9761c1c1f916161278a99284d50a594939Marshall Clowtemplate <class T, class A0> 34933afa9761c1c1f916161278a99284d50a594939Marshall Clowvoid test_is_constructible() 35933afa9761c1c1f916161278a99284d50a594939Marshall Clow{ 36933afa9761c1c1f916161278a99284d50a594939Marshall Clow static_assert( (std::is_constructible<T, A0>::value), ""); 37933afa9761c1c1f916161278a99284d50a594939Marshall Clow} 38933afa9761c1c1f916161278a99284d50a594939Marshall Clow 39933afa9761c1c1f916161278a99284d50a594939Marshall Clowtemplate <class T, class A0, class A1> 40933afa9761c1c1f916161278a99284d50a594939Marshall Clowvoid test_is_constructible() 41933afa9761c1c1f916161278a99284d50a594939Marshall Clow{ 42933afa9761c1c1f916161278a99284d50a594939Marshall Clow static_assert( (std::is_constructible<T, A0, A1>::value), ""); 43933afa9761c1c1f916161278a99284d50a594939Marshall Clow} 44933afa9761c1c1f916161278a99284d50a594939Marshall Clow 45933afa9761c1c1f916161278a99284d50a594939Marshall Clowtemplate <class T> 46933afa9761c1c1f916161278a99284d50a594939Marshall Clowvoid test_is_not_constructible() 47933afa9761c1c1f916161278a99284d50a594939Marshall Clow{ 48933afa9761c1c1f916161278a99284d50a594939Marshall Clow static_assert((!std::is_constructible<T>::value), ""); 49933afa9761c1c1f916161278a99284d50a594939Marshall Clow} 50933afa9761c1c1f916161278a99284d50a594939Marshall Clow 51933afa9761c1c1f916161278a99284d50a594939Marshall Clowtemplate <class T, class A0> 52933afa9761c1c1f916161278a99284d50a594939Marshall Clowvoid test_is_not_constructible() 53933afa9761c1c1f916161278a99284d50a594939Marshall Clow{ 54933afa9761c1c1f916161278a99284d50a594939Marshall Clow static_assert((!std::is_constructible<T, A0>::value), ""); 55933afa9761c1c1f916161278a99284d50a594939Marshall Clow} 56933afa9761c1c1f916161278a99284d50a594939Marshall Clow 57c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantint main() 58c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant{ 59933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_constructible<int> (); 60933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_constructible<int, const int> (); 61933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_constructible<A, int> (); 62933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_constructible<A, int, double> (); 63933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_constructible<int&, int&> (); 64933afa9761c1c1f916161278a99284d50a594939Marshall Clow 65933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_not_constructible<A> (); 66933afa9761c1c1f916161278a99284d50a594939Marshall Clow#if __has_feature(cxx_access_control_sfinae) 67933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_not_constructible<A, char> (); 68933afa9761c1c1f916161278a99284d50a594939Marshall Clow#else 69933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_constructible<A, char> (); 70933afa9761c1c1f916161278a99284d50a594939Marshall Clow#endif 71933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_not_constructible<A, void> (); 72933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_not_constructible<void> (); 73933afa9761c1c1f916161278a99284d50a594939Marshall Clow test_is_not_constructible<int&> (); 74c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant} 75