@@ -3077,14 +3077,14 @@ conjunction with `hana::when` to achieve a great deal of expressiveness.
30773077@subsection tutorial-core-concepts Emulation of C++ concepts
30783078
30793079The implementation of concepts in Hana is very simple. At its heart, a concept
3080- is just a template `struct` with a nested `::%value` boolean representing
3081- whether the given type is a _model_ of the concept:
3080+ is just a template `struct` that inherits from a boolean `integral_constant`
3081+ representing whether the given type is a _model_ of the concept:
30823082
30833083@code{cpp}
30843084template <typename T>
3085- struct Concept {
3086- static constexpr bool value = whether T models Concept;
3087- };
3085+ struct Concept
3086+ : hana::integral_constant< bool, whether T models Concept>
3087+ { };
30883088@endcode
30893089
30903090Then, one can test whether a type `T` is a model of `Concept` by looking at
@@ -3108,9 +3108,9 @@ that can be `print`ed. Our end goal is to have a template struct such as
31083108
31093109@code{cpp}
31103110template <typename T>
3111- struct Printable {
3112- static constexpr bool value = whether print_impl<tag of T> is defined;
3113- };
3111+ struct Printable
3112+ : hana::integral_constant< bool, whether print_impl<tag of T> is defined>
3113+ { };
31143114@endcode
31153115
31163116To know whether `print_impl<...>` has been defined, we'll modify `print_impl`
@@ -3124,14 +3124,13 @@ inherit from that `special_base_class` type:
31243124
31253125@snippet example/tutorial/concepts.cpp special_base_class_customize
31263126
3127- As you can see, `Printable<T>::%value` really only checks whether the
3128- `print_impl<T>` struct was specialized by a custom type. In particular,
3129- it does not even check whether the nested `::%apply` function is defined
3130- or if it is syntactically valid. It is assumed that if one specializes
3131- `print_impl` for a custom type, the nested `::%apply` function exists and
3132- is correct. If it is not, a compilation error will be triggered when one
3133- tries to call `print` on an object of that type. Concepts in Hana make the
3134- same assumptions.
3127+ As you can see, `Printable<T>` really only checks whether the `print_impl<T>`
3128+ struct was specialized by a custom type. In particular, it does not even check
3129+ whether the nested `::%apply` function is defined or if it is syntactically
3130+ valid. It is assumed that if one specializes `print_impl` for a custom type,
3131+ the nested `::%apply` function exists and is correct. If it is not, a compilation
3132+ error will be triggered when one tries to call `print` on an object of that type.
3133+ Concepts in Hana make the same assumptions.
31353134
31363135Since this pattern of inheriting from a special base class is quite abundant
31373136in Hana, the library provides a dummy type called `hana::default_` that can be
0 commit comments