From 6f0b0d77a8ad6ca03371e80e64e4ee1d03ffb711 Mon Sep 17 00:00:00 2001 From: Peter McLean Date: Fri, 8 Aug 2025 15:24:54 -0400 Subject: [PATCH 1/2] Add additional from_string variants --- .../bitlib/bit-algorithms/to_from_string.hpp | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/include/bitlib/bit-algorithms/to_from_string.hpp b/include/bitlib/bit-algorithms/to_from_string.hpp index e2d5eb1..084337e 100644 --- a/include/bitlib/bit-algorithms/to_from_string.hpp +++ b/include/bitlib/bit-algorithms/to_from_string.hpp @@ -1,7 +1,7 @@ -// ================================= array_REF =================================== // +// ============================= to_from_string ============================= // // Project: The Experimental Bit Algorithms Library -// \file to_string.hpp -// Description: Implementation of array_ref +// \file to_from_string.hpp +// Description: Implementation of to_string and from_string // Creator: Vincent Reverdy // Contributor: Peter McLean [2025] // License: BSD 3-Clause License @@ -275,7 +275,7 @@ constexpr CharIt to_string( return to_string(bits, str_first, str_last, meta); } -template > +template ::value_type>> constexpr void from_string( const CharIt str_first, const CharIt str_last, const bit_iterator& bit_first, const bit_iterator& bit_last, @@ -356,7 +356,7 @@ constexpr void from_string( template > + typename Policy = policy::typical::value_type>> constexpr void from_string( const CharIt str_first, const CharIt str_last, const bit_iterator& bit_first, const bit_iterator& bit_last) { @@ -410,7 +410,7 @@ constexpr std::vector from_string( return from_string(first, last, meta); } -template > +template ::value_type>> constexpr void from_string( const std::string& str, const bit_iterator& bit_first, const bit_iterator& bit_last) { @@ -418,7 +418,7 @@ constexpr void from_string( from_string(str.c_str(), str.c_str() + str.length(), bit_first, bit_last); } -template ::value_type>> +template ::word_type>> constexpr void from_string( const std::string& str, RangeT&& bits) { @@ -427,7 +427,7 @@ constexpr void from_string( from_string(str.begin(), str.end(), bits.begin(), bits.end()); } -template > +template ::value_type>> constexpr void from_string( const std::string& str, const bit_iterator& bit_first, const bit_iterator& bit_last, @@ -438,7 +438,7 @@ constexpr void from_string( meta); } -template ::value_type>> +template ::word_type>> constexpr void from_string( const std::string& str, RangeT&& bits, @@ -451,6 +451,25 @@ constexpr void from_string( meta); } +template ::word_type>> +constexpr void from_string( + const CharIt first, const CharIt last, + RangeT&& bits, + string::metadata_t meta = string::typical()) { + using range_iterator_t = std::ranges::iterator_t; + using RandomAccessIt = typename range_iterator_t::iterator_type; + from_string(first, last, bits.begin(), bits.end(), meta); +} + +template ::word_type>> +constexpr void from_string( + const CharIt first, const CharIt last, + RangeT&& bits) { + using range_iterator_t = std::ranges::iterator_t; + using RandomAccessIt = typename range_iterator_t::iterator_type; + return from_string(first, last, bits.begin(), bits.end(), meta); +} + } // namespace bit #endif // _BIT_TO_STRING_HPP_INCLUDED \ No newline at end of file From 39609adce9335c4404b03cbba8b97986f55133db Mon Sep 17 00:00:00 2001 From: Peter McLean Date: Fri, 8 Aug 2025 15:29:05 -0400 Subject: [PATCH 2/2] clang format --- include/bitlib/bit-algorithms/to_from_string.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bitlib/bit-algorithms/to_from_string.hpp b/include/bitlib/bit-algorithms/to_from_string.hpp index 084337e..c57ee3d 100644 --- a/include/bitlib/bit-algorithms/to_from_string.hpp +++ b/include/bitlib/bit-algorithms/to_from_string.hpp @@ -472,4 +472,4 @@ constexpr void from_string( } // namespace bit -#endif // _BIT_TO_STRING_HPP_INCLUDED \ No newline at end of file +#endif // _BIT_TO_STRING_HPP_INCLUDED \ No newline at end of file