|
||||
File indexing completed on 2025-01-18 09:37:58
0001 /*! 0002 @file 0003 Forward declares `boost::hana::IntegralConstant`. 0004 0005 Copyright Louis Dionne 2013-2022 0006 Distributed under the Boost Software License, Version 1.0. 0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 0008 */ 0009 0010 #ifndef BOOST_HANA_FWD_CONCEPT_INTEGRAL_CONSTANT_HPP 0011 #define BOOST_HANA_FWD_CONCEPT_INTEGRAL_CONSTANT_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 0015 0016 namespace boost { namespace hana { 0017 //! @ingroup group-concepts 0018 //! The `IntegralConstant` concept represents compile-time integral values. 0019 //! 0020 //! The `IntegralConstant` concept represents objects that hold a 0021 //! `constexpr` value of an integral type. In other words, it describes 0022 //! the essential functionality provided by `std::integral_constant`. 0023 //! An `IntegralConstant` is also just a special kind of `Constant` 0024 //! whose inner value is of an integral type. 0025 //! 0026 //! 0027 //! Minimal complete definition 0028 //! --------------------------- 0029 //! The requirements for being an `IntegralConstant` are quite simple. 0030 //! First, an `IntegralConstant` `C` must be a `Constant` such that 0031 //! `Tag::value_type` is an integral type, where `Tag` is the tag of `C`. 0032 //! 0033 //! Secondly, `C` must have a nested `static constexpr` member named 0034 //! `value`, such that the following code is valid: 0035 //! @code 0036 //! constexpr auto v = C::value; 0037 //! @endcode 0038 //! Because of the requirement that `Tag::value_type` be an integral type, 0039 //! it follows that `C::value` must be an integral value. 0040 //! 0041 //! Finally, it is necessary to specialize the `IntegralConstant` template 0042 //! in the `boost::hana` namespace to tell Hana that a type is a model 0043 //! of `IntegralConstant`: 0044 //! @code 0045 //! namespace boost { namespace hana { 0046 //! template <> 0047 //! struct IntegralConstant<your_custom_tag> { 0048 //! static constexpr bool value = true; 0049 //! }; 0050 //! }} 0051 //! @endcode 0052 //! 0053 //! 0054 //! Refined concept 0055 //! --------------- 0056 //! 1. `Constant` (free implementation of `value`)\n 0057 //! The `value` function required to be a `Constant` can be implemented 0058 //! as follows for `IntegralConstant`s: 0059 //! @code 0060 //! value<C>() == C::value 0061 //! @endcode 0062 //! The `to` function must still be provided explicitly for the model 0063 //! of `Constant` to be complete. 0064 //! 0065 //! 0066 //! Concrete models 0067 //! --------------- 0068 //! `hana::integral_constant` 0069 template <typename C> 0070 struct IntegralConstant; 0071 }} // end namespace boost::hana 0072 0073 #endif // !BOOST_HANA_FWD_CONCEPT_INTEGRAL_CONSTANT_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |