diff --git a/doc/html/declval.html b/doc/html/declval.html index 43dd657..305cf36 100644 --- a/doc/html/declval.html +++ b/doc/html/declval.html @@ -3,7 +3,7 @@
Copyright © 2008 Howard Hinnant
Copyright © 2009 -2012 Vicente J. Botet Escriba
Copyright © 2009-2012 Vicente + J. Botet Escriba
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)
@@ -43,7 +44,7 @@Table of Contents
-template<class T> -T&& declval(); // not used -+T&& declval(); // not used +
as part of the function template declaration
template<class To, class From> -decltype(static_cast<To>(declval<From>())) convert(From&&); +decltype(static_cast<To>(declval<From>())) convert(From&&);
or as part of a class template definition @@ -80,9 +81,9 @@
template<class> class result_of; template<class Fn, class... ArgTypes> -struct result_of<Fn(ArgTypes...)> +struct result_of<Fn(ArgTypes...)> { - typedef decltype(declval<Fn>()(declval<ArgTypes>()...)) type; + typedef decltype(declval<Fn>()(declval<ArgTypes>()...)) type; };
@@ -94,8 +95,8 @@ to
template<class T> -typename std::add_rvalue_reference<T>::type declval(); // not used -+typename std::add_rvalue_reference<T>::type declval(); // not used +
which ensures that we can also use cv void as template parameter. The careful
reader might have noticed that declval()
already exists under the name create() as
@@ -119,10 +120,10 @@
namespace boost { template <typename T> - typename add_rvalue_reference<T>::type declval() noexcept; // as unevaluated operand - -} // namespace boost -+ typename add_rvalue_reference<T>::type declval() noexcept; // as unevaluated operand + +} // namespace boost +
The library provides the function template declval to simplify the definition of expressions which occur as unevaluated operands. @@ -142,7 +143,7 @@ Example:
template <class To, class From> -decltype(static_cast<To>(declval<From>())) convert(From&&); +decltype(static_cast<To>(declval<From>())) convert(From&&);
Declares a function template convert which only participates in overloading @@ -153,21 +154,22 @@
-Fixes:
-Last revised: May 28, 2012 at 18:59:06 GMT |
+Last revised: November 23, 2013 at 14:11:12 GMT |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
Copyright © 2013 Andrey Semashev
+ 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) +
+
+ BOOST_EXPLICIT_OPERATOR_BOOL()
and BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()
are compatibility helper macros that expand
+ to an explicit conversion operator to bool
.
+ For compilers not supporting explicit conversion operators introduced in C++11
+ the macros expand to a conversion operator that implements the safe
+ bool idiom. In case if the compiler is not able to handle safe bool
+ idiom well the macros expand to a regular conversion operator to bool
.
+
+ Both macros are intended to be placed within a user's class definition. The
+ generated conversion operators will be implemented in terms of operator!()
+ that should be defined by user in this class. In case of BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()
the generated conversion operator will be
+ declared constexpr
which requires
+ the corresponding operator!()
+ to also be constexpr
.
+
template< typename T > +class my_ptr +{ + T* m_p; + +public: + BOOST_EXPLICIT_OPERATOR_BOOL() + + bool operator!() const + { + return !m_p; + } +}; ++
+ Now my_ptr
can be used in conditional
+ expressions, similarly to a regular pointer:
+
my_ptr< int > p; +if (p) + std::cout << "true" << std::endl; ++
Last revised: November 17, 2013 at 17:08:52 GMT |
++ |
Last revised: October 27, 2013 at 21:01:34 GMT |
+Last revised: November 23, 2013 at 14:12:56 GMT |