summaryrefslogtreecommitdiff
path: root/boost/hana/fwd
diff options
context:
space:
mode:
Diffstat (limited to 'boost/hana/fwd')
-rw-r--r--boost/hana/fwd/string.hpp30
-rw-r--r--boost/hana/fwd/take_back.hpp20
2 files changed, 41 insertions, 9 deletions
diff --git a/boost/hana/fwd/string.hpp b/boost/hana/fwd/string.hpp
index ab23d52aea..80c1622500 100644
--- a/boost/hana/fwd/string.hpp
+++ b/boost/hana/fwd/string.hpp
@@ -12,6 +12,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/hana/config.hpp>
#include <boost/hana/fwd/core/make.hpp>
+#include <boost/hana/fwd/core/to.hpp>
BOOST_HANA_NAMESPACE_BEGIN
@@ -94,16 +95,23 @@ BOOST_HANA_NAMESPACE_BEGIN
//! concepts as `hana::string` does.
//! @include example/string/to.cpp
//!
+ //! Conversion from any Constant holding a `char const*`
+ //! ----------------------------------------------------
+ //! A `hana::string` can be created from any `Constant` whose underlying
+ //! value is convertible to a `char const*` by using `hana::to`. The
+ //! contents of the `char const*` are used to build the content of the
+ //! `hana::string`.
+ //! @include example/string/from_c_str.cpp
//!
- //! > #### Rationale for `hana::string` not being a `Constant`
- //! > The underlying type held by a `hana::string` could be either
- //! > `char const*` or some other constexpr-enabled string-like container.
- //! > In the first case, `hana::string` can not be a `Constant` because
- //! > the models of several concepts would not be respected by the
- //! > underlying type, causing `value` not to be structure-preserving.
- //! > Providing an underlying value of constexpr-enabled string-like
- //! > container type like `std::string_view` would be great, but that's
- //! > a bit complicated for the time being.
+ //! Rationale for `hana::string` not being a `Constant` itself
+ //! ----------------------------------------------------------
+ //! The underlying type held by a `hana::string` could be either `char const*`
+ //! or some other constexpr-enabled string-like container. In the first case,
+ //! `hana::string` can not be a `Constant` because the models of several
+ //! concepts would not be respected by the underlying type, causing `value`
+ //! not to be structure-preserving. Providing an underlying value of
+ //! constexpr-enabled string-like container type like `std::string_view`
+ //! would be great, but that's a bit complicated for the time being.
template <typename implementation_defined>
struct string {
// Default-construct a `hana::string`; no-op since `hana::string` is stateless.
@@ -180,6 +188,10 @@ BOOST_HANA_NAMESPACE_BEGIN
//! @relates hana::string
constexpr auto make_string = make<string_tag>;
+ //! Equivalent to `to<string_tag>`; provided for convenience.
+ //! @relates hana::string
+ constexpr auto to_string = to<string_tag>;
+
//! Create a compile-time string from a parameter pack of characters.
//! @relates hana::string
//!
diff --git a/boost/hana/fwd/take_back.hpp b/boost/hana/fwd/take_back.hpp
index fa4dde5e3c..5ba1cf932f 100644
--- a/boost/hana/fwd/take_back.hpp
+++ b/boost/hana/fwd/take_back.hpp
@@ -53,6 +53,26 @@ BOOST_HANA_NAMESPACE_BEGIN
constexpr take_back_t take_back{};
#endif
+
+ //! Equivalent to `take_back`; provided for convenience.
+ //! @ingroup group-Sequence
+ //!
+ //!
+ //! Example
+ //! -------
+ //! @include example/take_back_c.cpp
+#ifdef BOOST_HANA_DOXYGEN_INVOKED
+ template <std::size_t n>
+ constexpr auto take_back_c = [](auto&& xs) {
+ return hana::take_back(forwarded(xs), hana::size_c<n>);
+ };
+#else
+ template <std::size_t n>
+ struct take_back_c_t;
+
+ template <std::size_t n>
+ constexpr take_back_c_t<n> take_back_c{};
+#endif
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_FWD_TAKE_BACK_HPP