@@ -12,6 +12,7 @@ Distributed under the Boost Software License, Version 1.0.
12
12
13
13
#include < boost/hana/config.hpp>
14
14
#include < boost/hana/fwd/core/make.hpp>
15
+ #include < boost/hana/fwd/core/to.hpp>
15
16
16
17
17
18
BOOST_HANA_NAMESPACE_BEGIN
@@ -94,16 +95,23 @@ BOOST_HANA_NAMESPACE_BEGIN
94
95
// ! concepts as `hana::string` does.
95
96
// ! @include example/string/to.cpp
96
97
// !
98
+ // ! Conversion from any Constant holding a `char const*`
99
+ // ! ----------------------------------------------------
100
+ // ! A `hana::string` can be created from any `Constant` whose underlying
101
+ // ! value is convertible to a `char const*` by using `hana::to`. The
102
+ // ! contents of the `char const*` are used to build the content of the
103
+ // ! `hana::string`.
104
+ // ! @include example/string/from_c_str.cpp
97
105
// !
98
- // ! > #### Rationale for `hana::string` not being a `Constant`
99
- // ! > The underlying type held by a `hana::string` could be either
100
- // ! > `char const*` or some other constexpr-enabled string-like container.
101
- // ! > In the first case, `hana:: string` can not be a `Constant` because
102
- // ! > the models of several concepts would not be respected by the
103
- // ! > underlying type, causing `value` not to be structure-preserving.
104
- // ! > Providing an underlying value of constexpr-enabled string-like
105
- // ! > container type like `std::string_view` would be great, but that's
106
- // ! > a bit complicated for the time being.
106
+ // ! Rationale for `hana::string` not being a `Constant` itself
107
+ // ! ----------------------------------------------------------
108
+ // ! The underlying type held by a `hana:: string` could be either `char const*`
109
+ // ! or some other constexpr-enabled string-like container. In the first case,
110
+ // ! `hana::string` can not be a `Constant` because the models of several
111
+ // ! concepts would not be respected by the underlying type, causing `value`
112
+ // ! not to be structure-preserving. Providing an underlying value of
113
+ // ! constexpr-enabled string-like container type like `std::string_view`
114
+ // ! would be great, but that's a bit complicated for the time being.
107
115
template <typename implementation_defined>
108
116
struct string {
109
117
// Default-construct a `hana::string`; no-op since `hana::string` is stateless.
@@ -180,6 +188,10 @@ BOOST_HANA_NAMESPACE_BEGIN
180
188
// ! @relates hana::string
181
189
constexpr auto make_string = make<string_tag>;
182
190
191
+ // ! Equivalent to `to<string_tag>`; provided for convenience.
192
+ // ! @relates hana::string
193
+ constexpr auto to_string = to<string_tag>;
194
+
183
195
// ! Create a compile-time string from a parameter pack of characters.
184
196
// ! @relates hana::string
185
197
// !
0 commit comments