forked from boostorg/type_traits
Add enable_if_ and enable_if_t. Sever dependency on Core.
This commit is contained in:
1 parent
7639c5820b
commit
2baafd4a3a
9 files changed
+183
-8
No files matched your search
@@ -0,0 +1,44 @@
|
||||
[/
|
||||
Copyright 2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License,
|
||||
Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
[section:enable_if enable_if_]
|
||||
|
||||
template<bool B, class T = void>
|
||||
struct enable_if_;
|
||||
|
||||
template<bool B, class T = void>
|
||||
using enable_if_t = typename enable_if_<B, T>::type;
|
||||
|
||||
__type If `B` is true, then the member `type` is defined to be `T`. Otherwise
|
||||
there is no member `type`.
|
||||
|
||||
__header `#include <boost/type_traits/enable_if.hpp>`
|
||||
|
||||
__examples
|
||||
|
||||
The following function can be used to destroy each element of an array and
|
||||
specially handle arrays of trivially destrucibtle types.
|
||||
|
||||
template<class T>
|
||||
typename boost::enable_if_<!boost::has_trivial_destructor<T>::value>::type
|
||||
destroy(T* ptr, std::size_t size)
|
||||
{
|
||||
while (size > 0) {
|
||||
ptr[--size].~T();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
typename boost::enable_if_<boost::has_trivial_destructor<T>::value>::type
|
||||
destroy(T*, std::size_t) { }
|
||||
|
||||
[all_compilers] The type alias `enable_if_t` is only available if the compiler
|
||||
supports template aliases.
|
||||
|
||||
[endsect]
|
||||
@@ -309,6 +309,7 @@ that is the result of the transformation.
|
||||
[include declval.qbk]
|
||||
[include detected.qbk]
|
||||
[include detected_or.qbk]
|
||||
[include enable_if.qbk]
|
||||
[include extent.qbk]
|
||||
[include floating_point_promotion.qbk]
|
||||
[include function_traits.qbk]
|
||||
|
||||
Reference in new issue
Block a user