Silicium
is_handle.hpp
Go to the documentation of this file.
1 #ifndef SILICIUM_IS_HANDLE_HPP
2 #define SILICIUM_IS_HANDLE_HPP
3 
4 #include <silicium/config.hpp>
5 #include <boost/static_assert.hpp>
6 
7 namespace Si
8 {
9 #if SILICIUM_COMPILER_HAS_WORKING_NOEXCEPT
10  template <class T>
11  struct is_handle : std::integral_constant<bool,
12  Si::is_nothrow_default_constructible<T>::value &&
13  Si::is_nothrow_move_assignable<T>::value &&
14  Si::is_nothrow_move_constructible<T>::value &&
15  Si::is_nothrow_destructible<T>::value
16  >
17  {
18  };
19 #else
20  template <class T>
21  struct is_handle : std::integral_constant<bool,
22  !std::is_const<T>::value &&
23  !std::is_reference<T>::value &&
24  Si::is_default_constructible<T>::value &&
25  Si::is_move_assignable<T>::value &&
26  Si::is_move_constructible<T>::value
27  >
28  {
29  };
30 #endif
31 
38  BOOST_STATIC_ASSERT(is_handle<int (*)()>::value);
43  BOOST_STATIC_ASSERT(is_handle<std::unique_ptr<int>>::value);
44 
45  namespace detail
46  {
47  struct non_copyable
48  {
50  };
52 
53 #ifndef _MSC_VER
55  {
57  };
58  //VC++ 2013 std::is_{move,copy}_assignable do not return the correct result
60 #if !SILICIUM_GCC || (SILICIUM_GCC > 406)
62 #endif
64 #endif
65 
66 #if SILICIUM_COMPILER_HAS_WORKING_NOEXCEPT
67  struct non_noexcept_move_constructible
68  {
69  non_noexcept_move_constructible(non_noexcept_move_constructible &&) BOOST_NOEXCEPT_IF(false);
70  };
71  BOOST_STATIC_ASSERT(!is_handle<non_noexcept_move_constructible>::value);
72 
73  struct non_noexcept_move_assignable
74  {
75  non_noexcept_move_assignable &operator = (non_noexcept_move_assignable &&) BOOST_NOEXCEPT_IF(false);
76  };
77  BOOST_STATIC_ASSERT(!is_handle<non_noexcept_move_assignable>::value);
78 #endif
79  }
80 }
81 
82 #endif
BOOST_STATIC_ASSERT(Si::is_handle< absolute_path >::value)
Definition: absolute_path.hpp:19
Definition: config.hpp:238
#define SILICIUM_DELETED_FUNCTION(f)
Definition: config.hpp:111
Definition: is_handle.hpp:21
Definition: is_handle.hpp:47
Definition: config.hpp:281
Definition: is_handle.hpp:54
BOOST_STATIC_ASSERT(!is_handle< non_copyable >::value)