is_empty.qbk 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. [/
  2. Copyright 2007 John Maddock.
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. ]
  7. [section:is_empty is_empty]
  8. template <class T>
  9. struct is_empty : public __tof {};
  10. __inherit If T is an empty class type (and not a union type) then inherits from __true_type,
  11. otherwise inherits from __false_type.
  12. __std_ref 10p5.
  13. __header ` #include <boost/type_traits/is_empty.hpp>` or ` #include <boost/type_traits.hpp>`
  14. __compat In order to correctly detect empty classes this trait relies on either:
  15. * the compiler implementing zero sized empty base classes, or
  16. * the compiler providing __intrinsics to detect empty classes - this latter case can be tested for
  17. by checking to see if the macro BOOST_IS_EMPTY is defined.
  18. Can not be used with incomplete types.
  19. __examples
  20. [:Given: `struct empty_class {};` ]
  21. [:`is_empty<empty_class>` inherits from `__true_type`.]
  22. [:`is_empty<empty_class const>::type` is the type `__true_type`.]
  23. [:`is_empty<empty_class>::value` is an integral constant
  24. expression that evaluates to /true/.]
  25. [:`is_empty<T>::value_type` is the type `bool`.]
  26. [endsect]