| 1 | /* |
| 2 | * Distributed under the Boost Software License, Version 1.0. |
| 3 | * (See accompanying file LICENSE_1_0.txt or copy at |
| 4 | * https://www.boost.org/LICENSE_1_0.txt) |
| 5 | * |
| 6 | * Copyright (c) 2023 Andrey Semashev |
| 7 | */ |
| 8 | /*! |
| 9 | * \file scope/detail/is_nonnull_default_constructible.hpp |
| 10 | * |
| 11 | * This header contains definition of \c is_nonnull_default_constructible |
| 12 | * and \c is_nothrow_nonnull_default_constructible type traits. The type |
| 13 | * traits are useful for preventing default-construction of pointers to |
| 14 | * functions where a default-constructed function object is expected. |
| 15 | * Without it, default- or value-constructing a pointer to function would |
| 16 | * produce a function object that is not callable. |
| 17 | */ |
| 18 | |
| 19 | #ifndef BOOST_SCOPE_DETAIL_IS_NONNULL_DEFAULT_CONSTRUCTIBLE_HPP_INCLUDED_ |
| 20 | #define BOOST_SCOPE_DETAIL_IS_NONNULL_DEFAULT_CONSTRUCTIBLE_HPP_INCLUDED_ |
| 21 | |
| 22 | #include <type_traits> |
| 23 | #include <boost/scope/detail/config.hpp> |
| 24 | #include <boost/scope/detail/header.hpp> |
| 25 | |
| 26 | #ifdef BOOST_HAS_PRAGMA_ONCE |
| 27 | #pragma once |
| 28 | #endif |
| 29 | |
| 30 | namespace boost { |
| 31 | namespace scope { |
| 32 | namespace detail { |
| 33 | |
| 34 | //! The type trait checks if \c T is not a pointer and is default-constructible |
| 35 | template< typename T > |
| 36 | struct is_nonnull_default_constructible : |
| 37 | public std::is_default_constructible< T > |
| 38 | { |
| 39 | }; |
| 40 | |
| 41 | template< typename T > |
| 42 | struct is_nonnull_default_constructible< T* > : |
| 43 | public std::false_type |
| 44 | { |
| 45 | }; |
| 46 | |
| 47 | //! The type trait checks if \c T is not a pointer and is nothrow-default-constructible |
| 48 | template< typename T > |
| 49 | struct is_nothrow_nonnull_default_constructible : |
| 50 | public std::is_nothrow_default_constructible< T > |
| 51 | { |
| 52 | }; |
| 53 | |
| 54 | template< typename T > |
| 55 | struct is_nothrow_nonnull_default_constructible< T* > : |
| 56 | public std::false_type |
| 57 | { |
| 58 | }; |
| 59 | |
| 60 | } // namespace detail |
| 61 | } // namespace scope |
| 62 | } // namespace boost |
| 63 | |
| 64 | #include <boost/scope/detail/footer.hpp> |
| 65 | |
| 66 | #endif // BOOST_SCOPE_DETAIL_IS_NONNULL_DEFAULT_CONSTRUCTIBLE_HPP_INCLUDED_ |
| 67 | |