#ifndef SPROUT_STRING_SHRINK_HPP #define SPROUT_STRING_SHRINK_HPP #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT namespace sprout { // // shrink_string // template class shrink_string { public: typedef sprout::basic_string string_type; private: typedef sprout::value_holder holder_type; public: typedef typename holder_type::param_type param_type; private: template static SPROUT_CONSTEXPR sprout::basic_string implicit_conversion_impl( T const(& elems)[M], std::size_t len, sprout::index_tuple ) { return sprout::basic_string{{(Indexes < M - 1 ? elems[Indexes] : T())...}, len}; } private: holder_type holder_; public: shrink_string(shrink_string const&) = default; shrink_string(shrink_string&&) = default; explicit SPROUT_CONSTEXPR shrink_string(param_type p) : holder_(p) {} template SPROUT_CONSTEXPR operator sprout::basic_string() const { return implicit_conversion_impl( holder_.get().elems, NS_SSCRISK_CEL_OR_SPROUT::min(N2, holder_.get().len), sprout::index_range<0, NS_SSCRISK_CEL_OR_SPROUT::min(N2, N)>::make() ); } }; // // shrink // template SPROUT_CONSTEXPR sprout::shrink_string shrink(sprout::basic_string const& s) { return sprout::shrink_string(s); } } // namespace sprout #endif // #ifndef SPROUT_STRING_SHRINK_HPP