integral_constant.qbk 862 B

123456789101112131415161718192021222324252627
  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:integral_constant integral_constant]
  8. template <class T, T val>
  9. struct integral_constant
  10. {
  11. typedef integral_constant<T, val> type;
  12. typedef T value_type;
  13. static const T value = val;
  14. constexpr operator T()const;
  15. };
  16. typedef integral_constant<bool, true> true_type;
  17. typedef integral_constant<bool, false> false_type;
  18. Class template `integral_constant` is the common base class for all the value-based
  19. type traits. The two typedef's `true_type` and `false_type` are provided for
  20. convenience: most of the value traits are Boolean properties and so will inherit from
  21. one of these.
  22. [endsect]