From 42f930860c2d892a8e7a2f6bc46e40169b528c76 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Tue, 22 Sep 2026 19:59:29 -0400 Subject: [PATCH 1/4] Reformat code --- .../daw/algorithms/daw_algorithm_accumulate.h | 17 +- include/daw/algorithms/daw_algorithm_copy.h | 3 +- include/daw/algorithms/daw_algorithm_copy_n.h | 3 +- include/daw/algorithms/daw_algorithm_find.h | 13 +- .../algorithms/daw_algorithm_find_transform.h | 11 +- .../algorithms/daw_algorithm_partial_sum.h | 6 +- include/daw/algorithms/daw_array_compare.h | 6 +- include/daw/algorithms/daw_enumerate_tuple.h | 62 ++++--- include/daw/compressed_pair.h | 6 +- include/daw/cpp_17.h | 46 +++--- include/daw/cpp_17_iterator.h | 6 +- include/daw/cpp_20.h | 4 +- include/daw/daw_algorithm.h | 78 +++++---- include/daw/daw_any_if.h | 16 +- include/daw/daw_apply.h | 7 +- include/daw/daw_atomic_wait.h | 22 +-- include/daw/daw_bind_args_at.h | 73 +++++---- include/daw/daw_bind_front.h | 10 +- include/daw/daw_bitset_helper.h | 8 +- include/daw/daw_bounded_array.h | 8 +- include/daw/daw_bounded_vector.h | 4 +- include/daw/daw_callable.h | 11 +- include/daw/daw_concepts.h | 102 ++++++------ include/daw/daw_constant.h | 11 +- include/daw/daw_construct_a.h | 2 +- include/daw/daw_container_algorithm.h | 51 +++--- include/daw/daw_contiguous_view.h | 28 ++-- include/daw/daw_cpp20_concept.h | 5 +- include/daw/daw_cx_atomic.h | 62 ++++--- include/daw/daw_cxmath.h | 3 +- include/daw/daw_dependent_false.h | 2 - include/daw/daw_enable_requires.h | 1 - include/daw/daw_exception.h | 3 +- include/daw/daw_format_range.h | 3 +- include/daw/daw_format_tuple.h | 16 +- include/daw/daw_from_string.h | 38 ++--- include/daw/daw_function_table.h | 4 +- include/daw/daw_fwd_pack_apply.h | 50 +++--- include/daw/daw_hash_set.h | 3 +- include/daw/daw_identity_function.h | 4 +- include/daw/daw_integer_reverse.h | 7 +- include/daw/daw_is_detected.h | 6 +- include/daw/daw_iter_view.h | 13 +- include/daw/daw_iterator_traits.h | 4 +- include/daw/daw_maybe_unique_ptr.h | 39 ++--- include/daw/daw_memory_mapped_file.h | 59 ++++--- include/daw/daw_metro_hash.h | 42 ++--- include/daw/daw_min_perfect_hash.h | 32 ++-- include/daw/daw_move_only.h | 4 +- include/daw/daw_move_only_base.h | 4 +- include/daw/daw_mutable_function_ref.h | 70 ++++---- include/daw/daw_named_params.h | 4 +- include/daw/daw_nth_pack_element.h | 3 +- include/daw/daw_observer_ptr.h | 13 +- include/daw/daw_parse_to.h | 26 +-- include/daw/daw_parser_addons.h | 47 +++--- include/daw/daw_parser_helper.h | 33 ++-- include/daw/daw_pipelines.h | 2 +- include/daw/daw_poly_value.h | 29 ++-- include/daw/daw_print.h | 8 +- include/daw/daw_print_ostream.h | 7 +- include/daw/daw_random.h | 4 +- include/daw/daw_ref_storage.h | 20 ++- include/daw/daw_safe_pointer.h | 8 +- include/daw/daw_sbo.h | 4 +- include/daw/daw_shared_function.h | 14 +- include/daw/daw_sort_n.h | 15 +- include/daw/daw_span_writer.h | 28 ++-- include/daw/daw_stack_function.h | 7 +- include/daw/daw_tracked_allocator.h | 4 +- include/daw/daw_tuple.h | 18 ++- include/daw/daw_tuple2.h | 15 +- include/daw/daw_tuple_helper.h | 70 ++++---- include/daw/daw_utility.h | 30 ++-- include/daw/daw_visit.h | 29 ++-- include/daw/daw_visit_as.h | 37 +++-- include/daw/deprecated/daw_bounded_string.h | 72 ++++----- include/daw/deprecated/daw_checked_expected.h | 10 +- include/daw/deprecated/daw_cstring.h | 6 +- include/daw/deprecated/daw_fixed_array.h | 16 +- include/daw/deprecated/daw_heap_value.h | 5 +- include/daw/deprecated/daw_optional_poly.h | 42 +++-- include/daw/deprecated/daw_ordered_map.h | 15 +- include/daw/deprecated/daw_range_algorithm.h | 78 ++++----- include/daw/deprecated/daw_range_collection.h | 3 +- include/daw/deprecated/daw_range_operators.h | 11 +- .../deprecated/daw_range_parallel_operators.h | 27 ++-- include/daw/deprecated/daw_range_reference.h | 3 +- include/daw/deprecated/daw_safe_string.h | 10 +- include/daw/deprecated/daw_string.h | 41 ++--- include/daw/deprecated/daw_string_fmt.h | 36 ++--- include/daw/deprecated/daw_string_view1.h | 65 ++++---- include/daw/deprecated/daw_vector.h | 13 +- include/daw/deprecated/not_null.h | 5 +- include/daw/impl/daw_container_help_impl.h | 6 +- include/daw/impl/daw_container_help_ins_ext.h | 6 +- include/daw/impl/daw_container_help_string.h | 51 +++--- include/daw/impl/daw_container_help_vector.h | 41 +++-- include/daw/impl/daw_int_to_iterator.h | 3 +- include/daw/impl/daw_is_string_view_like.h | 29 ++-- include/daw/impl/daw_make_trait.h | 24 +-- include/daw/impl/daw_string_impl.h | 47 +++--- include/daw/impl/daw_traits_impl.h | 20 +-- include/daw/iterator/daw_split_iterator.h | 8 +- include/daw/pipelines/algorithm.h | 35 ++-- include/daw/pipelines/cache_last_view.h | 12 +- include/daw/pipelines/chunk.h | 10 +- include/daw/pipelines/concat.h | 16 +- include/daw/pipelines/counted_source.h | 4 +- include/daw/pipelines/daw_concept_checker.h | 23 +-- include/daw/pipelines/elements.h | 63 +++++--- include/daw/pipelines/every.h | 7 +- include/daw/pipelines/filter.h | 31 ++-- include/daw/pipelines/find.h | 30 ++-- include/daw/pipelines/flatten.h | 12 +- include/daw/pipelines/map.h | 81 ++++++---- include/daw/pipelines/maybe.h | 3 +- include/daw/pipelines/maybe_owning_range.h | 3 +- include/daw/pipelines/numeric.h | 6 +- include/daw/pipelines/pipeline.h | 4 +- include/daw/pipelines/range_base.h | 6 +- include/daw/pipelines/reverse.h | 3 +- include/daw/pipelines/sized_iterator.h | 46 ++++-- include/daw/pipelines/slide.h | 10 +- include/daw/pipelines/split.h | 7 +- include/daw/pipelines/take.h | 4 +- include/daw/pipelines/to.h | 4 +- include/daw/pipelines/unique.h | 17 +- include/daw/pipelines/view.h | 30 ++-- include/daw/pipelines/zip.h | 61 ++++--- include/daw/split_buffer.h | 43 ++--- include/daw/traits/daw_traits_is_a_type.h | 18 +-- .../daw/traits/daw_traits_is_ostream_like.h | 15 +- include/daw/traits/daw_traits_nth_element.h | 2 +- include/daw/vector.h | 153 +++++++++--------- include/daw/wrap_iter.h | 4 +- 136 files changed, 1528 insertions(+), 1491 deletions(-) diff --git a/include/daw/algorithms/daw_algorithm_accumulate.h b/include/daw/algorithms/daw_algorithm_accumulate.h index a8a13c2aa..01f162ea3 100644 --- a/include/daw/algorithms/daw_algorithm_accumulate.h +++ b/include/daw/algorithms/daw_algorithm_accumulate.h @@ -21,9 +21,8 @@ namespace daw::algorithm { template inline constexpr bool is_container_like_v< - C, - std::void_t( ).begin( ) ), - ( (void)std::declval( ).end( ) ) )>> = + C, std::void_t( ).begin( ) ), + ( (void)std::declval( ).end( ) ) )>> = true; struct plus { @@ -34,8 +33,8 @@ namespace daw::algorithm { }; } // namespace accum_impl template - constexpr auto - accumulate( InputIterator first, InputIterator last, T init ) noexcept { + constexpr auto accumulate( InputIterator first, InputIterator last, + T init ) noexcept { DAW_UNSAFE_BUFFER_FUNC_START for( ; first != last; ++first ) { init = std::move( init ) + *first; @@ -57,16 +56,12 @@ namespace daw::algorithm { * @param binary_op operation to run * @return sum of values */ - template, std::nullptr_t> = nullptr> constexpr auto accumulate( - InputIterator first, - LastType last, - T init, + InputIterator first, LastType last, T init, BinaryOperation binary_op = BinaryOperation{ } ) noexcept( noexcept( binary_op( std::move( init ), *first ) ) ) { diff --git a/include/daw/algorithms/daw_algorithm_copy.h b/include/daw/algorithms/daw_algorithm_copy.h index 692bfef9d..a391a0d5f 100644 --- a/include/daw/algorithms/daw_algorithm_copy.h +++ b/include/daw/algorithms/daw_algorithm_copy.h @@ -23,8 +23,7 @@ namespace daw::algorithm { /// @return end of output range written to template constexpr OutputIterator - copy( InputIterator first, - LastType last, + copy( InputIterator first, LastType last, OutputIterator first_out ) noexcept( noexcept( *first_out = *first ) ) { traits::is_input_iterator_test( ); diff --git a/include/daw/algorithms/daw_algorithm_copy_n.h b/include/daw/algorithms/daw_algorithm_copy_n.h index faecd2c02..af215bd1a 100644 --- a/include/daw/algorithms/daw_algorithm_copy_n.h +++ b/include/daw/algorithms/daw_algorithm_copy_n.h @@ -22,8 +22,7 @@ namespace daw::algorithm { /// @return end of output range written to template constexpr auto - copy_n( InputIterator first, - OutputIterator first_out, + copy_n( InputIterator first, OutputIterator first_out, size_t count ) noexcept( noexcept( *first_out = *first ) ) { traits::is_input_iterator_test( ); diff --git a/include/daw/algorithms/daw_algorithm_find.h b/include/daw/algorithms/daw_algorithm_find.h index 90d046e7d..11001d82c 100644 --- a/include/daw/algorithms/daw_algorithm_find.h +++ b/include/daw/algorithms/daw_algorithm_find.h @@ -31,10 +31,9 @@ namespace daw::algorithm { } template - [[nodiscard]] constexpr InputIterator find_first_of( InputIterator first, - InputIterator last, - ForwardIterator sfirst, - ForwardIterator slast ) { + [[nodiscard]] constexpr InputIterator + find_first_of( InputIterator first, InputIterator last, + ForwardIterator sfirst, ForwardIterator slast ) { (void)daw::traits::is_input_iterator_test( ); (void)daw::traits::is_forward_access_iterator_test( ); @@ -50,11 +49,9 @@ namespace daw::algorithm { return last; } - template - constexpr InputIterator find_if( InputIterator first, - InputIteratorLast last, + constexpr InputIterator find_if( InputIterator first, InputIteratorLast last, UnaryPredicate &&unary_predicate ) { daw::traits::is_input_iterator_test( ); daw::traits::is_unary_predicate_test( ); diff --git a/include/daw/algorithms/daw_algorithm_find_transform.h b/include/daw/algorithms/daw_algorithm_find_transform.h index b7a9f143c..92fa773f6 100644 --- a/include/daw/algorithms/daw_algorithm_find_transform.h +++ b/include/daw/algorithms/daw_algorithm_find_transform.h @@ -27,14 +27,11 @@ namespace daw::algorithm { /// It minimizes the cost when the transformation is expensive and /// only calls it once per element until the predicate returns true /// on the transformed result - template - constexpr find_transform_result_t find_transform( Iterator first, - IteratorLast last, - Func &&func, - Pred &&pred ) { + constexpr find_transform_result_t + find_transform( Iterator first, IteratorLast last, Func &&func, + Pred &&pred ) { while( first != last ) { auto result = func( *first ); if( pred( result ) ) { diff --git a/include/daw/algorithms/daw_algorithm_partial_sum.h b/include/daw/algorithms/daw_algorithm_partial_sum.h index 2f1dcdc63..4d7bf784e 100644 --- a/include/daw/algorithms/daw_algorithm_partial_sum.h +++ b/include/daw/algorithms/daw_algorithm_partial_sum.h @@ -14,12 +14,10 @@ #include namespace daw::algorithm { - template constexpr OutputIterator - partial_sum( InputIterator first, - InputIterator last, + partial_sum( InputIterator first, InputIterator last, OutputIterator first_out, BinaryOperator op = BinaryOperator{ } ) { diff --git a/include/daw/algorithms/daw_array_compare.h b/include/daw/algorithms/daw_array_compare.h index cf322f8fb..9a4e90694 100644 --- a/include/daw/algorithms/daw_array_compare.h +++ b/include/daw/algorithms/daw_array_compare.h @@ -33,9 +33,9 @@ namespace daw { remove_array_ref_t>> DAW_ATTRIB_FLATTEN constexpr auto array_cmp( T &&lhs, T &&rhs, Compare const &cmp = Compare{ } ) { - using compare_result_t = - std::invoke_result_t, - std::remove_all_extents_t>; + using compare_result_t = std::invoke_result_t, + std::remove_all_extents_t>; for( std::size_t n = 0; n < std::extent_v; ++n ) { auto r = [&] { if constexpr( std::rank_v > 1 ) { diff --git a/include/daw/algorithms/daw_enumerate_tuple.h b/include/daw/algorithms/daw_enumerate_tuple.h index 257e7b8c5..36e844f0a 100644 --- a/include/daw/algorithms/daw_enumerate_tuple.h +++ b/include/daw/algorithms/daw_enumerate_tuple.h @@ -8,11 +8,11 @@ #pragma once +#include "daw/cpp_17.h" #include "daw/daw_concepts.h" #include "daw/daw_constant.h" -#include "daw_enumerate_tuple.h" -#include "daw/cpp_17.h" #include "daw/daw_move.h" +#include "daw_enumerate_tuple.h" #include #include @@ -29,9 +29,10 @@ namespace daw { value_t value; template - requires ( I >= 0 and I < 2 ) - constexpr decltype(auto) operator[]( this Self &&self, daw::constant ) { - if constexpr(I == 0) { + requires( I >= 0 and I < 2 ) + constexpr decltype( auto ) operator[]( this Self &&self, + daw::constant ) { + if constexpr( I == 0 ) { return Self::index; } else { return std::forward_like( self.value ); @@ -40,14 +41,11 @@ namespace daw { }; template - concept EnumeratedTuple = requires - { - typename std::remove_cvref_t::i_am_an_enumerated_tuple; - }; + concept EnumeratedTuple = + requires { typename std::remove_cvref_t::i_am_an_enumerated_tuple; }; template - concept EnumeratedTupleElement = requires - { + concept EnumeratedTupleElement = requires { typename std::remove_cvref_t::i_am_an_enumerated_tuple_element; }; @@ -55,12 +53,12 @@ namespace daw { using enumerated_tuple_index_t = typename std::remove_cvref_t::index_t; template - using enumerated_tuple_element_index_t = typename std::remove_cvref_t< - T>::index_t; + using enumerated_tuple_element_index_t = + typename std::remove_cvref_t::index_t; template - using enumerated_tuple_element_value_t = typename std::remove_cvref_t< - T>::value_t; + using enumerated_tuple_element_value_t = + typename std::remove_cvref_t::value_t; template struct enumerated_tuple_t { @@ -71,24 +69,24 @@ namespace daw { template constexpr auto operator[]( this Self &&self, daw::constant ) { - static constexpr auto i = static_cast(Idx); - using element_t = decltype( std::get( - std::forward_like( self.m_tuple ) ) ); - return enumerate_tuple_element_t(Idx)>{ - std::get( std::forward_like( self.m_tuple ) )}; + static constexpr auto i = static_cast( Idx ); + using element_t = + decltype( std::get( std::forward_like( self.m_tuple ) ) ); + return enumerate_tuple_element_t( Idx )>{ + std::get( std::forward_like( self.m_tuple ) ) }; } }; template constexpr enumerated_tuple_t enumerate_tuple( Tp &&tp ) { - return {DAW_FWD( tp )}; + return { DAW_FWD( tp ) }; } -} +} // namespace daw namespace std { template - inline constexpr std::size_t tuple_size_v = std::tuple_size_v::tuple_t>; + inline constexpr std::size_t tuple_size_v = + std::tuple_size_v::tuple_t>; template struct tuple_size { @@ -106,19 +104,19 @@ namespace std { template struct tuple_element { using index_t = daw::enumerated_tuple_index_t; - static constexpr index_t index = static_cast(I); + static constexpr index_t index = static_cast( I ); using type_t = std::tuple_element_t>; using type = daw::enumerate_tuple_element_t; }; template - requires( Idx == 0 ) + requires( Idx == 0 ) struct tuple_element { using type = daw::enumerated_tuple_element_index_t; }; template - requires( Idx == 1 ) + requires( Idx == 1 ) struct tuple_element { using type = daw::enumerated_tuple_element_value_t; }; @@ -126,19 +124,19 @@ namespace std { template constexpr auto get( EnumeratedTuple &&tp ) { using index_t = typename std::remove_cvref_t::index_t; - static constexpr index_t index = static_cast(Idx); + static constexpr index_t index = static_cast( Idx ); using value_t = decltype( std::get( DAW_FWD( tp ).m_tuple ) ); return daw::enumerate_tuple_element_t{ - std::get( DAW_FWD( tp ).m_tuple )}; + std::get( DAW_FWD( tp ).m_tuple ) }; } template - constexpr decltype(auto) get( EnumeratedTupleElement &&element ) { - if constexpr(I == 0) { + constexpr decltype( auto ) get( EnumeratedTupleElement &&element ) { + if constexpr( I == 0 ) { return element.index; } else { return DAW_FWD( element ).value; } } -} \ No newline at end of file +} // namespace std \ No newline at end of file diff --git a/include/daw/compressed_pair.h b/include/daw/compressed_pair.h index 9a79ed978..640003811 100644 --- a/include/daw/compressed_pair.h +++ b/include/daw/compressed_pair.h @@ -105,9 +105,9 @@ namespace daw { using Base2 = compressed_pair_elem; template - requires( std::is_default_constructible_v - and std::is_default_constructible_v ) // - explicit constexpr compressed_pair( ) + requires( std::is_default_constructible_v and + std::is_default_constructible_v ) + explicit constexpr compressed_pair( ) : Base1( value_init_tag( ) ) , Base2( value_init_tag( ) ) {} diff --git a/include/daw/cpp_17.h b/include/daw/cpp_17.h index 328a9cccf..c9d78c9b3 100644 --- a/include/daw/cpp_17.h +++ b/include/daw/cpp_17.h @@ -31,7 +31,7 @@ namespace daw { template inline constexpr bool conjunction_v = - ( static_cast(Ts::value) and ... ); + ( static_cast( Ts::value ) and ... ); template using conjunction_t = std::bool_constant>; @@ -60,24 +60,24 @@ namespace daw { not_fn_t( ) = default; explicit constexpr not_fn_t( Function &&func ) noexcept( - std::is_nothrow_move_constructible_v ) - : m_function{std::move( func )} {} + std::is_nothrow_move_constructible_v ) + : m_function{ std::move( func ) } {} explicit constexpr not_fn_t( Function const &func ) noexcept( - std::is_nothrow_copy_constructible_v ) - : m_function{func} {} + std::is_nothrow_copy_constructible_v ) + : m_function{ func } {} template [[nodiscard]] constexpr decltype( auto ) - operator( )( Args &&... args ) noexcept( - std::is_nothrow_invocable_v ) { + operator( )( Args &&...args ) noexcept( + std::is_nothrow_invocable_v ) { return not m_function( DAW_FWD( args )... ); } template [[nodiscard]] constexpr decltype( auto ) - operator( )( Args &&... args ) const - noexcept( std::is_nothrow_invocable_v ) { + operator( )( Args &&...args ) const + noexcept( std::is_nothrow_invocable_v ) { return not m_function( DAW_FWD( args )... ); } }; @@ -99,7 +99,7 @@ namespace daw { template inline constexpr bool is_reference_wrapper_v> = - true; + true; template using is_reference_wrapper = std::bool_constant>; @@ -115,7 +115,7 @@ namespace daw { template [[nodiscard]] constexpr auto size( Container const &c ) noexcept( noexcept( c.size( ) ) ) - -> decltype( c.size( ) ) { + -> decltype( c.size( ) ) { return c.size( ); } @@ -132,9 +132,9 @@ namespace daw { #undef min #endif template - [[nodiscard]] constexpr std::common_type_t ( min )( - T const &lhs, U const &rhs ) noexcept { - if(lhs <= rhs) { + [[nodiscard]] constexpr std::common_type_t( min )( + T const &lhs, U const &rhs ) noexcept { + if( lhs <= rhs ) { return lhs; } return rhs; @@ -143,19 +143,19 @@ namespace daw { template [[nodiscard]] constexpr T clamp( T val, U const &min_val, V const &max_val ) noexcept { - if(val < min_val) { + if( val < min_val ) { val = min_val; - } else if(val > max_val) { + } else if( val > max_val ) { val = max_val; } return val; } } // namespace math - } // namespace cpp_17_details + } // namespace cpp_17_details template inline constexpr bool disjunction_v = - ( static_cast(Ts::value) or ... ); + ( static_cast( Ts::value ) or ... ); template using disjunction_t = std::bool_constant>; @@ -186,23 +186,23 @@ namespace daw { template struct do_is_nothrow_convertible { using type = - decltype( do_is_nothrow_convertible_impl::test( 0 ) ); + decltype( do_is_nothrow_convertible_impl::test( 0 ) ); }; } // namespace cpp_17_details template struct is_nothrow_convertible - : cpp_17_details::do_is_nothrow_convertible::type {}; + : cpp_17_details::do_is_nothrow_convertible::type {}; template inline constexpr bool is_nothrow_convertible_v = - is_nothrow_convertible::value; + is_nothrow_convertible::value; template [[nodiscard]] constexpr auto decay_copy( T &&v ) noexcept( is_nothrow_convertible_v> ) - -> std::enable_if_t>, - std::decay_t> { + -> std::enable_if_t>, + std::decay_t> { return DAW_FWD( v ); } diff --git a/include/daw/cpp_17_iterator.h b/include/daw/cpp_17_iterator.h index 822c21163..61b754cb8 100644 --- a/include/daw/cpp_17_iterator.h +++ b/include/daw/cpp_17_iterator.h @@ -98,7 +98,8 @@ namespace daw { first, second, typename std::iterator_traits::iterator_category{ } ) ) ) { return cpp_17_details::distance_impl( - first, second, + first, + second, typename std::iterator_traits::iterator_category{ } ); } @@ -110,7 +111,8 @@ namespace daw { template constexpr void advance( Iterator &it, Distance n ) { cpp_17_details::advance( - it, static_cast( n ), + it, + static_cast( n ), typename std::iterator_traits::iterator_category{ } ); } diff --git a/include/daw/cpp_20.h b/include/daw/cpp_20.h index 007d62a80..40c5429e1 100644 --- a/include/daw/cpp_20.h +++ b/include/daw/cpp_20.h @@ -63,9 +63,7 @@ namespace daw { #if defined( DAW_HAS_CPP20_CONCEPTS ) template inline constexpr bool has_pointer_traits_to_address_v = - requires( T const &p ) { - std::pointer_traits::to_address( p ); - }; + requires( T const &p ) { std::pointer_traits::to_address( p ); }; #else template inline constexpr bool has_pointer_traits_to_address_v = false; diff --git a/include/daw/daw_algorithm.h b/include/daw/daw_algorithm.h index 81526c51c..90e827f87 100644 --- a/include/daw/daw_algorithm.h +++ b/include/daw/daw_algorithm.h @@ -146,8 +146,8 @@ namespace daw { using std::begin; using std::end; auto const d = static_cast( distance ); - algorithm_details::safe_advance_impl( begin( container ), it, - end( container ), d ); + algorithm_details::safe_advance_impl( + begin( container ), it, end( container ), d ); } /// @brief Advance Iterator within the bounds of container @@ -167,8 +167,8 @@ namespace daw { using std::begin; using std::end; auto const d = static_cast( distance ); - algorithm_details::safe_advance_impl( begin( container ), it, - end( container ), d ); + algorithm_details::safe_advance_impl( + begin( container ), it, end( container ), d ); } /// @brief Advance iterator n steps forward but do not go past last. @@ -903,10 +903,10 @@ namespace daw::algorithm { traits::is_input_iterator_test( ); traits::is_input_iterator_test( ); - traits::is_compare_test( ); - traits::is_compare_test( ); + traits:: + is_compare_test( ); + traits:: + is_compare_test( ); while( ( first1 != last1 ) and ( first2 != last2 ) ) { if( daw::invoke( comp, *first1, *first2 ) ) { @@ -931,7 +931,8 @@ namespace daw::algorithm { traits::is_input_iterator_test( ); traits::is_input_iterator_test( ); - static_assert( std::is_invocable_v ); static_assert( std::is_invocable_v ); @@ -1234,8 +1235,8 @@ namespace daw::algorithm { traits::is_input_iterator_test( ); traits::is_input_iterator_test( ); - traits::is_compare_test( ); + traits:: + is_compare_test( ); while( ( first1 != last1 ) and ( first2 != last2 ) and daw::invoke( comp, *first1, *first2 ) ) { @@ -1266,8 +1267,8 @@ namespace daw::algorithm { traits::is_input_iterator_test( ); traits::is_input_iterator_test( ); - traits::is_compare_test( ); + traits:: + is_compare_test( ); while( ( first1 != last1 ) and ( first2 != last2 ) and comp( *first1, *first2 ) ) { @@ -1479,7 +1480,8 @@ namespace daw::algorithm { traits::is_input_iterator_test( ); traits::is_input_iterator_test( ); traits::is_output_iterator_test( ); - traits::is_binary_predicate_test( ); while( first1 != last1 ) { @@ -1539,22 +1541,24 @@ namespace daw::algorithm { "requirements of the Iterator concept " "http://en.cppreference.com/w/cpp/concept/Iterator" ); - static_assert( - traits::is_binary_predicate_v, - "BinaryOperation map_func passed take two values " - "referenced by first. e.g map_func( *first1, " - "*first2 ) must be valid" ); + static_assert( traits::is_binary_predicate_v, + "BinaryOperation map_func passed take two values " + "referenced by first. e.g map_func( *first1, " + "*first2 ) must be valid" ); static_assert( - traits::is_binary_predicate_v, "BinaryOperation reduce_func must take two values referenced by first. " "e.g reduce_func( init, " "map_func( *first1, *first2 ) ) must be valid" ); while( first1 != last1 ) { - init = daw::invoke( reduce_func, std::move( init ), + init = daw::invoke( reduce_func, + std::move( init ), daw::invoke( map_func, *first1, *first2 ) ); ++first1; ++first2; @@ -1836,8 +1840,8 @@ namespace daw::algorithm { transform_many( InputIt1 first1, InputIt1 last1, InputIt2 first2, OutputIt first_out, Func func ) { - return cartesian_product_map( std::move( func ), first1, last1, first_out, - first2 ); + return cartesian_product_map( + std::move( func ), first1, last1, first_out, first2 ); } template - requires( (Fn or std::convertible_to) and ...) - constexpr bool any_if( Predicates && ...predicates ) { - constexpr auto const do_test = []( auto && p ) -> bool { - if constexpr( Fn ) { + template + requires( ( Fn or + std::convertible_to ) and + ... ) + constexpr bool any_if( Predicates &&...predicates ) { + constexpr auto const do_test = []( auto &&p ) -> bool { + if constexpr( Fn ) { return p( ); } else { return static_cast( p ); } }; - return (do_test( DAW_FWD( predicates ) ) and ...); + return ( do_test( DAW_FWD( predicates ) ) and ... ); } -} +} // namespace daw diff --git a/include/daw/daw_apply.h b/include/daw/daw_apply.h index 7da9cf674..a68bbeca4 100644 --- a/include/daw/daw_apply.h +++ b/include/daw/daw_apply.h @@ -115,8 +115,8 @@ namespace daw { std::reference_wrapper< Args>... args ) noexcept( std::is_nothrow_invocable_v ) { - return cpp_17_details::INVOKE( DAW_FWD( f ), DAW_FWD( arg ), - DAW_FWD( args )... ); + return cpp_17_details::INVOKE( + DAW_FWD( f ), DAW_FWD( arg ), DAW_FWD( args )... ); } #else template @@ -153,7 +153,8 @@ namespace daw { return daw::invoke( DAW_FWD( f ) ); } else { return cpp_17_details::apply_details( - DAW_FWD( f ), DAW_FWD( t ), + DAW_FWD( f ), + DAW_FWD( t ), std::make_index_sequence>>{ } ); } } else { diff --git a/include/daw/daw_atomic_wait.h b/include/daw/daw_atomic_wait.h index 86d2692a4..f1c0d3425 100644 --- a/include/daw/daw_atomic_wait.h +++ b/include/daw/daw_atomic_wait.h @@ -112,8 +112,8 @@ namespace daw { auto const is_timed_out = current_time >= final_time; return is_timed_out; }; - (void)atomic_impl::poll_with_backoff( atomic_impl::timed_backoff_policy, - poll_fn, rel_time ); + (void)atomic_impl::poll_with_backoff( + atomic_impl::timed_backoff_policy, poll_fn, rel_time ); if( current == old ) { return wait_status::timeout; } @@ -148,8 +148,8 @@ namespace daw { std::chrono::time_point const &timeout_time, std::memory_order order = std::memory_order_acquire ) { - return daw::atomic_wait_for( object, std::move( old ), - timeout_time - Clock::now( ), order ); + return daw::atomic_wait_for( + object, std::move( old ), timeout_time - Clock::now( ), order ); } /** @@ -233,8 +233,8 @@ namespace daw { auto const is_timed_out = current_time >= final_time; return is_timed_out; }; - (void)atomic_impl::poll_with_backoff( atomic_impl::timed_backoff_policy, - poll_fn, rel_time ); + (void)atomic_impl::poll_with_backoff( + atomic_impl::timed_backoff_policy, poll_fn, rel_time ); if( predicate( current_value ) ) { return wait_status::found; } @@ -270,8 +270,8 @@ namespace daw { std::atomic const *object, Fn auto &&predicate, std::chrono::time_point const &timeout_time, std::memory_order order = std::memory_order_acquire ) { - return daw::atomic_wait_if_for( object, std::move( predicate ), - timeout_time - Clock::now( ), order ); + return daw::atomic_wait_if_for( + object, std::move( predicate ), timeout_time - Clock::now( ), order ); } template @@ -331,7 +331,8 @@ namespace daw { [&desired_value]( T const ¤t_value ) { return current_value == desired_value; }, - rel_time, order ); + rel_time, + order ); } /** @@ -366,7 +367,8 @@ namespace daw { [&desired_value]( T const ¤t_value ) { return current_value == desired_value; }, - timeout_time - Clock::now( ), order ); + timeout_time - Clock::now( ), + order ); } } // namespace daw diff --git a/include/daw/daw_bind_args_at.h b/include/daw/daw_bind_args_at.h index 90cbe69af..07bca6a72 100644 --- a/include/daw/daw_bind_args_at.h +++ b/include/daw/daw_bind_args_at.h @@ -10,8 +10,8 @@ #include "daw/ciso646.h" #include "daw/cpp_17.h" -#include "daw/daw_is_detected.h" #include "daw/daw_cpp20_concept.h" +#include "daw/daw_is_detected.h" #include "daw/daw_move.h" #include "daw/daw_remove_cvref.h" @@ -80,23 +80,23 @@ namespace daw { split_args( std::forward_as_tuple( DAW_FWD( std::declval( ) )... ) ) ) )>; -namespace bind_args_impl { - template - DAW_CPP20_CONCEPT can_call_v = - daw::is_detected_v, - Invokable, TpArgs, Args...>; -} + namespace bind_args_impl { + template + DAW_CPP20_CONCEPT can_call_v = + daw::is_detected_v, + Invokable, TpArgs, Args...>; + } -namespace bind_args_impl { - template - DAW_CPP20_CONCEPT is_nothrow_callable_v = noexcept( std::apply( - std::declval( ), - std::tuple_cat( split_args<0, N>( std::forward_as_tuple( - DAW_FWD( std::declval( ) )... ) ), - std::declval( ), - split_args( std::forward_as_tuple( - DAW_FWD( std::declval( ) )... ) ) ) ) ); -} + namespace bind_args_impl { + template + DAW_CPP20_CONCEPT is_nothrow_callable_v = noexcept( std::apply( + std::declval( ), + std::tuple_cat( split_args<0, N>( std::forward_as_tuple( + DAW_FWD( std::declval( ) )... ) ), + std::declval( ), + split_args( std::forward_as_tuple( + DAW_FWD( std::declval( ) )... ) ) ) ) ); + } template struct bind_args_at_fn { @@ -104,36 +104,41 @@ namespace bind_args_impl { TpArgs tp_args; template, - std::nullptr_t> = nullptr> - constexpr decltype( auto ) operator( )( Args &&...args ) const - noexcept( bind_args_impl::is_nothrow_callable_v ) { + std::enable_if_t< + bind_args_impl::can_call_v, + std::nullptr_t> = nullptr> + constexpr decltype( auto ) operator( )( Args &&...args ) const noexcept( + bind_args_impl::is_nothrow_callable_v ) { return std::apply( - func, std::tuple_cat( - split_args<0, N>( std::forward_as_tuple( DAW_FWD( args )... ) ), - tp_args, - split_args( - std::forward_as_tuple( DAW_FWD( args )... ) ) ) ); + func, + std::tuple_cat( + split_args<0, N>( std::forward_as_tuple( DAW_FWD( args )... ) ), + tp_args, + split_args( + std::forward_as_tuple( DAW_FWD( args )... ) ) ) ); } template, - std::nullptr_t> = nullptr> + std::enable_if_t< + bind_args_impl::can_call_v, + std::nullptr_t> = nullptr> constexpr decltype( auto ) operator( )( Args &&...args ) noexcept( bind_args_impl::is_nothrow_callable_v ) { static_assert( N <= sizeof...( Args ) ); return std::apply( - func, std::tuple_cat( - split_args<0, N>( std::forward_as_tuple( DAW_FWD( args )... ) ), - tp_args, - split_args( - std::forward_as_tuple( DAW_FWD( args )... ) ) ) ); + func, + std::tuple_cat( + split_args<0, N>( std::forward_as_tuple( DAW_FWD( args )... ) ), + tp_args, + split_args( + std::forward_as_tuple( DAW_FWD( args )... ) ) ) ); } }; template constexpr auto bind_args_at( Invokable &&func, Args &&...args ) { - return bind_args_at_fn, + return bind_args_at_fn, std::tuple...>>{ DAW_FWD( func ), std::tuple...>( DAW_FWD( args )... ) }; diff --git a/include/daw/daw_bind_front.h b/include/daw/daw_bind_front.h index 979dba6ad..978f0c8b1 100644 --- a/include/daw/daw_bind_front.h +++ b/include/daw/daw_bind_front.h @@ -28,8 +28,9 @@ namespace daw { static_assert( std::is_invocable_v, "Arguments are not valid for function" ); return std::apply( - m_func, std::tuple_cat( m_params, - std::forward_as_tuple( DAW_FWD( args )... ) ) ); + m_func, + std::tuple_cat( m_params, + std::forward_as_tuple( DAW_FWD( args )... ) ) ); } template @@ -37,8 +38,9 @@ namespace daw { static_assert( std::is_invocable_v, "Arguments are not valid for function" ); return std::apply( - m_func, std::tuple_cat( m_params, - std::forward_as_tuple( DAW_FWD( args )... ) ) ); + m_func, + std::tuple_cat( m_params, + std::forward_as_tuple( DAW_FWD( args )... ) ) ); } }; diff --git a/include/daw/daw_bitset_helper.h b/include/daw/daw_bitset_helper.h index 23387b4f4..778801e7d 100644 --- a/include/daw/daw_bitset_helper.h +++ b/include/daw/daw_bitset_helper.h @@ -36,10 +36,10 @@ namespace daw { } // namespace create_bs_impl template - requires( std::ranges::range - and daw::traits::IntegerEnum> ) // - DAW_ATTRIB_FLATTEN DAW_CPP23_CX_BITSET_FN - auto create_bitset_from_set_positions( R const &r ) { + requires( std::ranges::range and + daw::traits::IntegerEnum> ) + DAW_ATTRIB_FLATTEN DAW_CPP23_CX_BITSET_FN auto + create_bitset_from_set_positions( R const &r ) { return create_bs_impl::create_bitset_from_set_positions( r ); } diff --git a/include/daw/daw_bounded_array.h b/include/daw/daw_bounded_array.h index 77075d083..e533df33a 100644 --- a/include/daw/daw_bounded_array.h +++ b/include/daw/daw_bounded_array.h @@ -101,15 +101,15 @@ namespace daw { template constexpr bool operator==( array const &lhs, array const &rhs ) { - return daw::algorithm::equal( lhs.cbegin( ), lhs.cend( ), rhs.cbegin( ), - rhs.cend( ) ); + return daw::algorithm::equal( + lhs.cbegin( ), lhs.cend( ), rhs.cbegin( ), rhs.cend( ) ); } template constexpr bool operator!=( array const &lhs, array const &rhs ) { - return not daw::algorithm::equal( lhs.cbegin( ), lhs.cend( ), rhs.cbegin( ), - rhs.cend( ) ); + return not daw::algorithm::equal( + lhs.cbegin( ), lhs.cend( ), rhs.cbegin( ), rhs.cend( ) ); } template diff --git a/include/daw/daw_bounded_vector.h b/include/daw/daw_bounded_vector.h index fbaf5057a..bb63af040 100644 --- a/include/daw/daw_bounded_vector.h +++ b/include/daw/daw_bounded_vector.h @@ -49,9 +49,9 @@ namespace daw { bounded_vector_t( ) = default; constexpr bounded_vector_t( const_pointer ptr, size_type count ) noexcept - : m_index{ ( daw::min )( count, N ) } { + : m_index{ (daw::min)( count, N ) } { - daw::algorithm::copy_n( ptr, m_stack.begin( ), ( daw::min )( count, N ) ); + daw::algorithm::copy_n( ptr, m_stack.begin( ), (daw::min)( count, N ) ); } template diff --git a/include/daw/daw_callable.h b/include/daw/daw_callable.h index e7be4b29f..a39a3d2e5 100644 --- a/include/daw/daw_callable.h +++ b/include/daw/daw_callable.h @@ -18,18 +18,19 @@ namespace daw { #if defined( DAW_HAS_CPP20_CONCEPTS ) template - concept is_callable_r_v = requires( Fn && fn, Args &&...args ) { - { std::forward( fn )( std::forward( args )... ) } - ->std::convertible_to; + concept is_callable_r_v = requires( Fn &&fn, Args &&...args ) { + { + std::forward( fn )( std::forward( args )... ) + } -> std::convertible_to; }; template - concept is_callable_v = requires( Fn && fn, Args &&...args ) { + concept is_callable_v = requires( Fn &&fn, Args &&...args ) { std::forward( fn )( std::forward( args )... ); }; template - concept is_nothrow_r_v = requires( Fn && fn, Args &&...args ) { + concept is_nothrow_r_v = requires( Fn &&fn, Args &&...args ) { { std::forward( fn )( std::forward( args )... ) } noexcept -> std::convertible_to; diff --git a/include/daw/daw_concepts.h b/include/daw/daw_concepts.h index da8ec598a..9ade11589 100644 --- a/include/daw/daw_concepts.h +++ b/include/daw/daw_concepts.h @@ -30,9 +30,8 @@ namespace daw { * convertible to type To. */ template - concept explicitly_convertible_to = requires { - static_cast( std::declval( ) ); - }; + concept explicitly_convertible_to = + requires { static_cast( std::declval( ) ); }; /*** * @brief Given types From and To and an expression E whose type and value @@ -106,10 +105,10 @@ namespace daw { */ template concept constructible_from = - std::destructible and requires( Args && ...args ) { - To{ DAW_FWD( args )... }; - }; // use std::is_constructible_v; - // once clang supports it for aggregates + std::destructible and requires( Args &&...args ) { + To{ DAW_FWD( args )... }; + }; // use std::is_constructible_v; + // once clang supports it for aggregates template concept constructible = constructible_from; @@ -125,16 +124,16 @@ namespace daw { }; template - concept ContiguousContainer = requires( T && container ) { - { std::data( container ) }->Pointers; - { std::size( container ) }->convertible_to; + concept ContiguousContainer = requires( T &&container ) { + { std::data( container ) } -> Pointers; + { std::size( container ) } -> convertible_to; }; template concept ContiguousContainerOf = ContiguousContainer and requires( T container ) { - { *std::data( container ) }->convertible_to; - }; + { *std::data( container ) } -> convertible_to; + }; template concept StringLike = @@ -182,7 +181,7 @@ namespace daw { * @tparam Args Arguments to call callable with */ template - concept invocable = requires( Func && f, Args &&...args ) { + concept invocable = requires( Func &&f, Args &&...args ) { std::invoke( DAW_FWD( f ), DAW_FWD( args )... ); }; @@ -195,8 +194,8 @@ namespace daw { std::assignable_from; #else std::is_lvalue_reference_v and requires( LHS lhs, RHS &&rhs ) { - { lhs = DAW_FWD( rhs ) }->std::same_as; - }; + { lhs = DAW_FWD( rhs ) } -> std::same_as; + }; #endif /// @brief Satisfied if T is a reference type, or if it is an object type @@ -215,9 +214,8 @@ namespace daw { namespace swappable_test { using namespace std; template - inline constexpr bool swappable_test = requires( T & a, T &b ) { - swap( a, b ); - }; + inline constexpr bool swappable_test = + requires( T &a, T &b ) { swap( a, b ); }; } // namespace swappable_test #endif @@ -249,11 +247,11 @@ namespace daw { std::weakly_incrementable; #else movable and requires( I i ) { - typename iter_difference_t; - requires SignedStd>; - { ++i }->same_as; - i++; - }; + typename iter_difference_t; + requires SignedStd>; + { ++i } -> same_as; + i++; + }; #endif /*** @@ -265,8 +263,10 @@ namespace daw { * @tparam Args Arguments to call callable with */ template - concept invocable_result = requires( Func && f, Args &&...args ) { - { std::invoke( DAW_FWD( f ), DAW_FWD( args )... ) }->convertible_to; + concept invocable_result = requires( Func &&f, Args &&...args ) { + { + std::invoke( DAW_FWD( f ), DAW_FWD( args )... ) + } -> convertible_to; }; template @@ -275,9 +275,8 @@ namespace daw { std::input_or_output_iterator; #else requires( I i ) { - { *i }; - } - and weakly_incrementable; + { *i }; + } and weakly_incrementable; #endif template @@ -285,12 +284,13 @@ namespace daw { #if defined( __cpp_lib_concepts ) std::indirectly_writable; #else - requires( Out && o, T &&t ) { - *o = DAW_FWD( t ); - *DAW_FWD( o ) = DAW_FWD( t ); - const_cast &&>( *o ) = DAW_FWD( t ); - const_cast &&>( *DAW_FWD( o ) ) = DAW_FWD( t ); - }; + requires( Out &&o, T &&t ) { + *o = DAW_FWD( t ); + *DAW_FWD( o ) = DAW_FWD( t ); + const_cast &&>( *o ) = DAW_FWD( t ); + const_cast &&>( *DAW_FWD( o ) ) = + DAW_FWD( t ); + }; #endif template @@ -305,8 +305,8 @@ namespace daw { #else input_or_output_iterator and indirectly_writable and requires( I i, T &&t ) { - *i++ = DAW_FWD( t ); // not required to be equality-preserving - }; + *i++ = DAW_FWD( t ); // not required to be equality-preserving + }; #endif template @@ -353,8 +353,8 @@ namespace daw { concept BackInsertableContainer = Containers and requires( Container c, typename Container::value_type const &v ) { - c.push_back( v ); - }; + c.push_back( v ); + }; #if not defined( __cpp_lib_concepts ) namespace concept_details { @@ -368,20 +368,20 @@ namespace daw { /// types template concept boolean_testable = - concept_details::boolean_testable_impl and requires( B && b ) { - { not DAW_FWD( b ) }->concept_details::boolean_testable_impl; - }; + concept_details::boolean_testable_impl and requires( B &&b ) { + { not DAW_FWD( b ) } -> concept_details::boolean_testable_impl; + }; namespace concept_details { template concept weakly_equality_comparable_with = requires( std::remove_reference_t const &t, std::remove_reference_t const &u ) { - { t == u }->boolean_testable; - { t != u }->boolean_testable; - { u == t }->boolean_testable; - { u != t }->boolean_testable; - }; + { t == u } -> boolean_testable; + { t != u } -> boolean_testable; + { u == t } -> boolean_testable; + { u != t } -> boolean_testable; + }; } // namespace concept_details #endif @@ -415,9 +415,7 @@ namespace daw { std::is_move_constructible_v; template - concept default_constructible = requires { - T{ }; - }; + concept default_constructible = requires { T{ }; }; template concept Integer = (same_as and std::is_integral_v) or @@ -450,13 +448,11 @@ namespace daw { template concept Callable_r = requires( Fn fn, Args... args ) { - { fn( args... ) }->convertible_to; + { fn( args... ) } -> convertible_to; }; template - concept Callable = requires( Fn fn, Args... args ) { - fn( args... ); - }; + concept Callable = requires( Fn fn, Args... args ) { fn( args... ); }; template concept NothrowCallable_r = requires( Fn fn, Args... args ) { diff --git a/include/daw/daw_constant.h b/include/daw/daw_constant.h index 200137a06..89f41f13e 100644 --- a/include/daw/daw_constant.h +++ b/include/daw/daw_constant.h @@ -27,24 +27,23 @@ namespace daw { } DAW_CPP23_STATIC_CALL_OP DAW_CONSTEVAL value_type operator( )( ) - DAW_CPP23_STATIC_CALL_OP_CONST noexcept { + DAW_CPP23_STATIC_CALL_OP_CONST noexcept { return Value; } }; template - inline constexpr auto constant_v = constant{}; + inline constexpr auto constant_v = constant{ }; namespace literals { template DAW_CONSTEVAL auto operator""_c( ) { static_assert( sizeof...( c ) != 0 ); constexpr auto buff_size = sizeof...( c ) + 1; - constexpr char buff[buff_size] = {c...}; + constexpr char buff[buff_size] = { c... }; using result_t = unsigned long long; - constexpr auto result = parser::parse_unsigned_int( - buff ); + constexpr auto result = parser::parse_unsigned_int( buff ); return daw::constant_v; } - } + } // namespace literals } // namespace daw \ No newline at end of file diff --git a/include/daw/daw_construct_a.h b/include/daw/daw_construct_a.h index 578070758..6ccfbefb7 100644 --- a/include/daw/daw_construct_a.h +++ b/include/daw/daw_construct_a.h @@ -9,12 +9,12 @@ #pragma once #include "daw/daw_attributes.h" +#include "daw/daw_cpp20_concept.h" #include "daw/daw_cpp_feature_check.h" #include "daw/daw_is_detected.h" #include "daw/daw_move.h" #include "daw/daw_traits.h" #include "daw/impl/daw_make_trait.h" -#include "daw/daw_cpp20_concept.h" #include diff --git a/include/daw/daw_container_algorithm.h b/include/daw/daw_container_algorithm.h index 4b91a889b..ed2533028 100644 --- a/include/daw/daw_container_algorithm.h +++ b/include/daw/daw_container_algorithm.h @@ -215,8 +215,8 @@ namespace daw::container { "http://en.cppreference.com/w/cpp/concept/Predicate for more " "information" ); - return std::partition( std::begin( container ), std::end( container ), - pred ); + return std::partition( + std::begin( container ), std::end( container ), pred ); } template, "Invalid BinaryOperation" ); - return std::accumulate( std::cbegin( container ), std::cend( container ), - DAW_FWD( init ), oper ); + return std::accumulate( + std::cbegin( container ), std::cend( container ), DAW_FWD( init ), oper ); } template, "UnaryOperator is not callable with the values stored in Container" ); - return std::transform( std::cbegin( container ), std::cend( container ), - std::begin( container ), unary_operator ); + return std::transform( std::cbegin( container ), + std::cend( container ), + std::begin( container ), + unary_operator ); } template, "Output of UnaryOperator cannot be assigned to *first_out" ); - return std::transform( std::cbegin( container ), std::cend( container ), - first_out, unary_operator ); + return std::transform( std::cbegin( container ), + std::cend( container ), + first_out, + unary_operator ); } template, "UnaryOperator is not callable with the values stored in Container" ); - std::transform( std::cbegin( container ), std::cend( container ), first_out, + std::transform( std::cbegin( container ), + std::cend( container ), + first_out, unary_operator ); } @@ -364,8 +371,8 @@ namespace daw::container { static_assert( traits::is_binary_predicate_v ); - return daw::algorithm::max_element( begin( container ), end( container ), - compare ); + return daw::algorithm::max_element( + begin( container ), end( container ), compare ); } template ); - return daw::algorithm::max_element( begin( container ), end( container ), - compare ); + return daw::algorithm::max_element( + begin( container ), end( container ), compare ); } template constexpr void append( Source const &source, Destination &destination ) { - destination.insert( std::end( destination ), std::begin( source ), - std::end( source ) ); + destination.insert( + std::end( destination ), std::begin( source ), std::end( source ) ); } } // namespace daw::container diff --git a/include/daw/daw_contiguous_view.h b/include/daw/daw_contiguous_view.h index e199b0672..aa6eb2e8a 100644 --- a/include/daw/daw_contiguous_view.h +++ b/include/daw/daw_contiguous_view.h @@ -28,8 +28,8 @@ namespace daw { struct contiguous_view; template - requires( not std::is_const_v ) // - struct contiguous_view { + requires( not std::is_const_v ) + struct contiguous_view { using value_type = T; using reference = value_type &; using const_reference = value_type const &; @@ -68,15 +68,15 @@ namespace daw { , m_last( first + sz ) {} template Container> - requires( not_cvref_of ) explicit( - ExplicitConv ) constexpr contiguous_view( Container &&c ) noexcept + requires( not_cvref_of ) + explicit( ExplicitConv ) constexpr contiguous_view( Container &&c ) noexcept : m_first( std::data( c ) ) , m_last( daw::data_end( c ) ) {} template Container> - requires( not_cvref_of ) explicit( - ExplicitConv ) constexpr contiguous_view( Container &&c, - std::size_t count ) noexcept + requires( not_cvref_of ) + explicit( ExplicitConv ) constexpr contiguous_view( + Container &&c, std::size_t count ) noexcept : m_first( std::data( c ) ) , m_last( std::next( m_first, static_cast( count ) ) ) { daw_ensure( count <= std::size( c ) ); @@ -430,8 +430,8 @@ namespace daw { }; template - requires( std::is_const_v ) // - struct contiguous_view { + requires( std::is_const_v ) + struct contiguous_view { using value_type = T; using reference = value_type &; using const_reference = value_type const &; @@ -465,15 +465,15 @@ namespace daw { , m_last( first + sz ) {} template Container> - requires( not_cvref_of ) explicit( - ExplicitConv ) constexpr contiguous_view( Container &&c ) noexcept + requires( not_cvref_of ) + explicit( ExplicitConv ) constexpr contiguous_view( Container &&c ) noexcept : m_first( std::data( c ) ) , m_last( daw::data_end( c ) ) {} template Container> - requires( not_cvref_of ) explicit( - ExplicitConv ) constexpr contiguous_view( Container &&c, - std::size_t count ) + requires( not_cvref_of ) + explicit( ExplicitConv ) constexpr contiguous_view( Container &&c, + std::size_t count ) : m_first( std::data( c ) ) , m_last( std::next( m_first, static_cast( count ) ) ) { daw_ensure( count <= std::size( c ) ); diff --git a/include/daw/daw_cpp20_concept.h b/include/daw/daw_cpp20_concept.h index 3ba4eb147..de3c3f60d 100644 --- a/include/daw/daw_cpp20_concept.h +++ b/include/daw/daw_cpp20_concept.h @@ -12,9 +12,8 @@ #if defined( DAW_HAS_CPP20_CONCEPTS ) #define DAW_CPP20_CONCEPT concept -#define DAW_CPP20_TYPENAME_CONSTRAINT(...) __VA_ARGS__ +#define DAW_CPP20_TYPENAME_CONSTRAINT( ... ) __VA_ARGS__ #else #define DAW_CPP20_CONCEPT inline constexpr bool -#define DAW_CPP20_TYPENAME_CONSTRAINT(...) typename +#define DAW_CPP20_TYPENAME_CONSTRAINT( ... ) typename #endif - diff --git a/include/daw/daw_cx_atomic.h b/include/daw/daw_cx_atomic.h index 3672ceca4..a31b03bc3 100644 --- a/include/daw/daw_cx_atomic.h +++ b/include/daw/daw_cx_atomic.h @@ -189,7 +189,8 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type fetch_add( this auto &self, value_type arg, std::memory_order m = std::memory_order::seq_cst ) noexcept - requires( not std::same_as ) { + requires( not std::same_as ) + { if consteval { (void)m; auto result = self.m_value; @@ -203,7 +204,8 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type fetch_sub( this auto &self, value_type arg, std::memory_order m = std::memory_order::seq_cst ) noexcept - requires( not std::same_as ) { + requires( not std::same_as ) + { if consteval { (void)m; auto result = self.m_value; @@ -216,7 +218,8 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type operator+=( this auto &self, value_type arg ) noexcept - requires( not std::same_as ) { + requires( not std::same_as ) + { if consteval { return self.m_value += arg; } else { @@ -226,7 +229,8 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type operator-=( this auto &self, value_type arg ) noexcept - requires( not std::same_as ) { + requires( not std::same_as ) + { if consteval { return self.m_value -= arg; } else { @@ -236,8 +240,9 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type operator++( this auto &self ) noexcept - requires( std::is_integral_v and - not std::same_as ) { + requires( std::is_integral_v and + not std::same_as ) + { if consteval { return ++self.m_value; } else { @@ -247,8 +252,9 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type operator++( this auto &self, int ) noexcept - requires( std::is_integral_v and - not std::same_as ) { + requires( std::is_integral_v and + not std::same_as ) + { if consteval { return self.m_value++; } else { @@ -258,8 +264,9 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type operator--( this auto &self ) noexcept - requires( std::is_integral_v and - not std::same_as ) { + requires( std::is_integral_v and + not std::same_as ) + { if consteval { return --self.m_value; } else { @@ -269,8 +276,9 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type operator--( this auto &self, int ) noexcept - requires( std::is_integral_v and - not std::same_as ) { + requires( std::is_integral_v and + not std::same_as ) + { if consteval { return self.m_value--; } else { @@ -281,8 +289,9 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type fetch_and( this auto &self, value_type arg, std::memory_order m = std::memory_order::seq_cst ) noexcept - requires( std::is_integral_v and - not std::same_as ) { + requires( std::is_integral_v and + not std::same_as ) + { if consteval { (void)m; auto result = self.m_value; @@ -296,8 +305,9 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type fetch_or( this auto &self, value_type arg, std::memory_order m = std::memory_order::seq_cst ) noexcept - requires( std::is_integral_v and - not std::same_as ) { + requires( std::is_integral_v and + not std::same_as ) + { if consteval { (void)m; auto result = self.m_value; @@ -311,8 +321,9 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type fetch_xor( this auto &self, value_type arg, std::memory_order m = std::memory_order::seq_cst ) noexcept - requires( std::is_integral_v and - not std::same_as ) { + requires( std::is_integral_v and + not std::same_as ) + { if consteval { (void)m; auto result = self.m_value; @@ -325,8 +336,9 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type operator&=( this auto &self, value_type arg ) - requires( std::is_integral_v and - not std::same_as ) { + requires( std::is_integral_v and + not std::same_as ) + { if consteval { return self.m_value &= arg; } else { @@ -336,8 +348,9 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type operator|=( this auto &self, value_type arg ) - requires( std::is_integral_v and - not std::same_as ) { + requires( std::is_integral_v and + not std::same_as ) + { if consteval { return self.m_value |= arg; } else { @@ -347,8 +360,9 @@ namespace daw { DAW_ATTRIB_FLATINLINE constexpr value_type operator^=( this auto &self, value_type arg ) - requires( std::is_integral_v and - not std::same_as ) { + requires( std::is_integral_v and + not std::same_as ) + { if consteval { return self.m_value ^= arg; } else { diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index 9663563bf..b9bac9436 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -991,8 +991,7 @@ namespace daw::cxmath { static_assert( not is_nan( daw::numeric_limits::infinity( ) ) ); #if defined( DAW_CX_BIT_CAST ) - [[nodiscard]] constexpr double ldexp( double d, - std::int32_t exponent ) { + [[nodiscard]] constexpr double ldexp( double d, std::int32_t exponent ) { daw::UInt64 dint = DAW_BIT_CAST( daw::UInt64, 2.0 ); auto const new_exponent = static_cast( static_cast( exponent ) + 1023U ); diff --git a/include/daw/daw_dependent_false.h b/include/daw/daw_dependent_false.h index b241bacea..dbfbe1632 100644 --- a/include/daw/daw_dependent_false.h +++ b/include/daw/daw_dependent_false.h @@ -12,5 +12,3 @@ namespace daw { template inline constexpr bool dependent_false_v = false; } - - diff --git a/include/daw/daw_enable_requires.h b/include/daw/daw_enable_requires.h index 9d1a6ffa5..79795fda6 100644 --- a/include/daw/daw_enable_requires.h +++ b/include/daw/daw_enable_requires.h @@ -13,7 +13,6 @@ #include #include - /// /// This helps in migrating to concepts as compiler support is added. #if defined( DAW_HAS_CPP20_CONCEPTS ) and not defined( DAW_NO_REQUIRES ) diff --git a/include/daw/daw_exception.h b/include/daw/daw_exception.h index 8e027b8db..4816c62ad 100644 --- a/include/daw/daw_exception.h +++ b/include/daw/daw_exception.h @@ -459,7 +459,8 @@ namespace daw::exception { Message &&assert_message, Predicate &&predicate ) { assert_all_false( - container, DAW_FWD( assert_message ), + container, + DAW_FWD( assert_message ), [pred = DAW_FWD( predicate )]( auto const &v ) { return not pred( v ); } ); diff --git a/include/daw/daw_format_range.h b/include/daw/daw_format_range.h index 96c31b3c7..b93983d65 100644 --- a/include/daw/daw_format_range.h +++ b/include/daw/daw_format_range.h @@ -67,7 +67,8 @@ namespace std { constexpr typename ParseContext::iterator parse( ParseContext &ctx DAW_LIFETIME_BOUND ) { auto ctx_b = std::begin( ctx ); - auto const ctx_sz = static_cast( std::distance( std::begin( ctx ), std::end( ctx ) ) ); + auto const ctx_sz = static_cast( + std::distance( std::begin( ctx ), std::end( ctx ) ) ); auto f = daw::basic_string_view( ctx_b, ctx_sz ); if( ctx.begin( ) == ctx.end( ) or *ctx.begin( ) == '}' ) { flags = "{}"; diff --git a/include/daw/daw_format_tuple.h b/include/daw/daw_format_tuple.h index 7c8e2b246..3894a042f 100644 --- a/include/daw/daw_format_tuple.h +++ b/include/daw/daw_format_tuple.h @@ -58,9 +58,11 @@ namespace std { formatter( ) = default; template - constexpr ParseContext::iterator parse( ParseContext &ctx DAW_LIFETIME_BOUND ) { + constexpr ParseContext::iterator + parse( ParseContext &ctx DAW_LIFETIME_BOUND ) { auto ctx_b = std::begin( ctx ); - auto const ctx_sz = static_cast( std::distance( std::begin( ctx ), std::end( ctx ) ) ); + auto const ctx_sz = static_cast( + std::distance( std::begin( ctx ), std::end( ctx ) ) ); auto f = daw::basic_string_view( ctx_b, ctx_sz ); if( ctx.begin( ) == ctx.end( ) or *ctx.begin( ) == '}' ) { flags = "{}"; @@ -114,14 +116,16 @@ namespace std { if( is_first ) { is_first = false; } else { - out = std::copy( std::data( c.Separator ), - daw::data_end( c.Separator ), out ); + out = std::copy( + std::data( c.Separator ), daw::data_end( c.Separator ), out ); } - out = std::vformat_to( out, std::string_view( flags ), + out = std::vformat_to( out, + std::string_view( flags ), std::make_format_args( get( c.value ) ) ); }; [&]( std::index_sequence ) { - (void)( write_value( std::integral_constant{ } ), ..., + (void)( write_value( std::integral_constant{ } ), + ..., 1 ); }( std::make_index_sequence>{ } ); out = std::copy( std::data( c.Right ), daw::data_end( c.Right ), out ); diff --git a/include/daw/daw_from_string.h b/include/daw/daw_from_string.h index 12eacef40..939a86488 100644 --- a/include/daw/daw_from_string.h +++ b/include/daw/daw_from_string.h @@ -13,26 +13,24 @@ #include "daw/daw_string_view.h" #include "daw/daw_utility.h" -#include #include +#include namespace daw::from_string_trait { template struct from_string_t {}; template - requires std::is_arithmetic_v + requires std::is_arithmetic_v struct from_string_t { explicit from_string_t( ) = default; - DAW_CPP23_STATIC_CALL_OP constexpr std::optional operator( - )( daw::string_view str ) DAW_CPP23_STATIC_CALL_OP_CONST { - I result = I{}; - std::from_chars_result fs_r = std::from_chars( - str.data( ), - str.data_end( ), - result ); - if(fs_r.ec == std::errc( )) { + DAW_CPP23_STATIC_CALL_OP constexpr std::optional + operator( )( daw::string_view str ) DAW_CPP23_STATIC_CALL_OP_CONST { + I result = I{ }; + std::from_chars_result fs_r = + std::from_chars( str.data( ), str.data_end( ), result ); + if( fs_r.ec == std::errc( ) ) { return result; } return std::nullopt; @@ -41,27 +39,25 @@ namespace daw::from_string_trait { namespace impl { template - concept StringConstructible = requires( char const *p, std::size_t sz ) - { - String( p, sz ); - }; - } + concept StringConstructible = + requires( char const *p, std::size_t sz ) { String( p, sz ); }; + } // namespace impl template struct from_string_t { explicit from_string_t( ) = default; - DAW_CPP23_STATIC_CALL_OP constexpr std::optional operator( - )( daw::string_view str ) DAW_CPP23_STATIC_CALL_OP_CONST { + DAW_CPP23_STATIC_CALL_OP constexpr std::optional + operator( )( daw::string_view str ) DAW_CPP23_STATIC_CALL_OP_CONST { return String( str.data( ), str.size( ) ); } }; -} +} // namespace daw::from_string_trait namespace daw { template - requires requires { daw::from_string_trait::from_string_t{}; } + requires requires { daw::from_string_trait::from_string_t{ }; } constexpr auto from_string( daw::tag_t, daw::string_view sv ) { - return daw::from_string_trait::from_string_t{}( sv ); + return daw::from_string_trait::from_string_t{ }( sv ); } -} \ No newline at end of file +} // namespace daw \ No newline at end of file diff --git a/include/daw/daw_function_table.h b/include/daw/daw_function_table.h index ab42e89d6..39f93a36c 100644 --- a/include/daw/daw_function_table.h +++ b/include/daw/daw_function_table.h @@ -77,8 +77,8 @@ namespace daw { } } if constexpr( is_t_in_range_v ) { - return apply_at_impl( idx, DAW_FWD( t ), - DAW_FWD( args )... ); + return apply_at_impl( + idx, DAW_FWD( t ), DAW_FWD( args )... ); } std::abort( ); } diff --git a/include/daw/daw_fwd_pack_apply.h b/include/daw/daw_fwd_pack_apply.h index 5129e6c8f..3d780c6a4 100644 --- a/include/daw/daw_fwd_pack_apply.h +++ b/include/daw/daw_fwd_pack_apply.h @@ -142,33 +142,33 @@ namespace daw { } // namespace daw namespace std { - template - struct tuple_size> { - static constexpr std::size_t value = sizeof...( Ts ); - }; + template + struct tuple_size> { + static constexpr std::size_t value = sizeof...( Ts ); + }; - template - struct tuple_element> { - using type = daw::traits::nth_type; - }; - } // namespace std + template + struct tuple_element> { + using type = daw::traits::nth_type; + }; +} // namespace std - namespace daw { - template - struct tuple_size; +namespace daw { + template + struct tuple_size; - template - struct [[deprecated( "use std::tuple_size" )]] - tuple_size> { - static constexpr std::size_t value = sizeof...( Ts ); - }; + template + struct [[deprecated( "use std::tuple_size" )]] + tuple_size> { + static constexpr std::size_t value = sizeof...( Ts ); + }; - template - struct tuple_element; + template + struct tuple_element; - template - struct [[deprecated( "use std::tuple_element" )]] - tuple_element> { - using type = daw::traits::nth_type; - }; - } // namespace daw + template + struct [[deprecated( "use std::tuple_element" )]] + tuple_element> { + using type = daw::traits::nth_type; + }; +} // namespace daw diff --git a/include/daw/daw_hash_set.h b/include/daw/daw_hash_set.h index 9aa39cf27..6a24c9092 100644 --- a/include/daw/daw_hash_set.h +++ b/include/daw/daw_hash_set.h @@ -98,7 +98,8 @@ namespace daw { [[nodiscard]] std::size_t size( ) const noexcept { return daw::algorithm::accumulate( std::begin( m_indices ), - std::end( m_indices ), std::size_t{ }, + std::end( m_indices ), + std::size_t{ }, []( auto const &opt ) { return opt.has_value( ) ? 1U : 0U; } ); diff --git a/include/daw/daw_identity_function.h b/include/daw/daw_identity_function.h index b7080becc..c56fb7d09 100644 --- a/include/daw/daw_identity_function.h +++ b/include/daw/daw_identity_function.h @@ -13,7 +13,7 @@ namespace daw { struct identity_function_t { - explicit identity_function_t() = default; + explicit identity_function_t( ) = default; template DAW_CPP23_STATIC_CALL_OP constexpr T && @@ -22,5 +22,5 @@ namespace daw { } }; - inline constexpr auto identity_function = identity_function_t{}; + inline constexpr auto identity_function = identity_function_t{ }; } // namespace daw diff --git a/include/daw/daw_integer_reverse.h b/include/daw/daw_integer_reverse.h index 4a41e2e51..9a49d325f 100644 --- a/include/daw/daw_integer_reverse.h +++ b/include/daw/daw_integer_reverse.h @@ -87,8 +87,11 @@ namespace daw::integers { std::uint32_t, std::uint64_t>, std::nullptr_t> = nullptr> [[nodiscard]] DAW_ATTRIB_NOINLINE constexpr T reverse_bits( T ) { - static_assert( daw::traits::is_one_of_v, + static_assert( daw::traits::is_one_of_v, "Unsupported integer type for bit reversal" ); } } // namespace daw::integers diff --git a/include/daw/daw_is_detected.h b/include/daw/daw_is_detected.h index d3f3bcbeb..a0efe7fce 100644 --- a/include/daw/daw_is_detected.h +++ b/include/daw/daw_is_detected.h @@ -8,9 +8,9 @@ #pragma once +#include "daw/daw_cpp20_concept.h" #include "daw/daw_cpp_feature_check.h" #include "daw/traits/daw_traits_is_same.h" -#include "daw/daw_cpp20_concept.h" #include #include @@ -35,9 +35,7 @@ namespace daw { #if defined( DAW_HAS_CPP20_CONCEPTS ) template class Op, class... Args> - concept is_detected_v = requires { - typename Op; - }; + concept is_detected_v = requires { typename Op; }; #endif namespace is_detect_details { template class Op, diff --git a/include/daw/daw_iter_view.h b/include/daw/daw_iter_view.h index c04105ab8..13747a19c 100644 --- a/include/daw/daw_iter_view.h +++ b/include/daw/daw_iter_view.h @@ -96,12 +96,9 @@ namespace daw { , m_size( sz ) {} template - requires( - ( Containers or ContiguousContainer ) and - not_cvref_of< - iter_view, - Container> ) explicit( ExplicitConv ) constexpr iter_view( Container && - c ) noexcept + requires( ( Containers or ContiguousContainer ) and + not_cvref_of ) + explicit( ExplicitConv ) constexpr iter_view( Container &&c ) noexcept : m_first( std::begin( c ) ) , m_last( std::end( c ) ) {} @@ -384,8 +381,8 @@ namespace daw { [[nodiscard]] friend constexpr bool operator<( iter_view const &x, iter_view const &y ) { - return std::lexicographical_compare( x.begin( ), x.end( ), y.begin( ), - y.end( ) ); + return std::lexicographical_compare( + x.begin( ), x.end( ), y.begin( ), y.end( ) ); } [[nodiscard]] friend constexpr bool operator>( iter_view const &x, diff --git a/include/daw/daw_iterator_traits.h b/include/daw/daw_iterator_traits.h index 34f83a954..4f6f25504 100644 --- a/include/daw/daw_iterator_traits.h +++ b/include/daw/daw_iterator_traits.h @@ -43,8 +43,8 @@ namespace daw { typename std::iterator_traits>::iterator_category; template - concept Iterator = requires( It & it ) { - { ++it }->std::same_as; + concept Iterator = requires( It &it ) { + { ++it } -> std::same_as; { it++ }; { *it }; }; diff --git a/include/daw/daw_maybe_unique_ptr.h b/include/daw/daw_maybe_unique_ptr.h index a42ff11fe..7e287bd00 100644 --- a/include/daw/daw_maybe_unique_ptr.h +++ b/include/daw/daw_maybe_unique_ptr.h @@ -34,8 +34,8 @@ namespace daw { : m_ptr( ptr ) {} template - requires( not std::is_pointer_v ) // - explicit constexpr maybe_unique_ptr( pointer ptr, B owned ) noexcept + requires( not std::is_pointer_v ) + explicit constexpr maybe_unique_ptr( pointer ptr, B owned ) noexcept : m_ptr( ptr ) , m_owned( owned ) {} @@ -44,15 +44,15 @@ namespace daw { : m_ptr( ptr, DAW_FWD( deleter ) ) {} template D, typename B> - requires( not std::is_pointer_v ) // - explicit constexpr maybe_unique_ptr( pointer ptr, D &&deleter, - B owned ) noexcept + requires( not std::is_pointer_v ) + explicit constexpr maybe_unique_ptr( pointer ptr, D &&deleter, + B owned ) noexcept : m_ptr( ptr, DAW_FWD( deleter ) ) , m_owned( owned ) {} template - requires( not std::is_same_v ) // - constexpr maybe_unique_ptr( U *p ) noexcept + requires( not std::is_same_v ) + constexpr maybe_unique_ptr( U *p ) noexcept : m_ptr( p ) { static_assert( unique_ptr_details::is_safe_child_type_v, "One cannot destruct U, if T does not have a virtual " @@ -60,8 +60,8 @@ namespace daw { } template - requires( not std::is_same_v and not std::is_pointer_v ) // - constexpr maybe_unique_ptr( U *p, B owned ) noexcept + requires( not std::is_same_v and not std::is_pointer_v ) + constexpr maybe_unique_ptr( U *p, B owned ) noexcept : m_ptr( p ) , m_owned( owned ) { static_assert( unique_ptr_details::is_safe_child_type_v, @@ -76,8 +76,8 @@ namespace daw { , m_owned( std::exchange( other.m_owned, true ) ) {} template - requires( not std::is_same_v ) // - constexpr maybe_unique_ptr( maybe_unique_ptr &&other ) noexcept + requires( not std::is_same_v ) + constexpr maybe_unique_ptr( maybe_unique_ptr &&other ) noexcept : Deleter( static_cast( other ) ) , m_ptr( other.release( ) ) , m_owned( std::exchange( other.m_owned, true ) ) { @@ -87,8 +87,8 @@ namespace daw { } template - requires( not std::is_same_v ) // - constexpr maybe_unique_ptr( unique_ptr &&other ) noexcept + requires( not std::is_same_v ) + constexpr maybe_unique_ptr( unique_ptr &&other ) noexcept : Deleter( std::move( other ).get_deleter( ) ) , m_ptr( other.release( ) ) { static_assert( unique_ptr_details::is_safe_child_type_v, @@ -106,9 +106,9 @@ namespace daw { } template - requires( not std::is_same_v ) // - constexpr maybe_unique_ptr & - operator=( maybe_unique_ptr &&rhs ) noexcept { + requires( not std::is_same_v ) + constexpr maybe_unique_ptr & + operator=( maybe_unique_ptr &&rhs ) noexcept { static_assert( unique_ptr_details::is_safe_child_type_v, "One cannot destruct U, if T does not have a virtual " "destructor, and U being a child of T" ); @@ -118,8 +118,8 @@ namespace daw { } template - requires( not std::is_same_v ) // - constexpr maybe_unique_ptr &operator=( unique_ptr &&rhs ) noexcept { + requires( not std::is_same_v ) + constexpr maybe_unique_ptr &operator=( unique_ptr &&rhs ) noexcept { static_assert( unique_ptr_details::is_safe_child_type_v, "One cannot destruct U, if T does not have a virtual " "destructor, and U being a child of T" ); @@ -202,7 +202,8 @@ namespace daw { } constexpr decltype( auto ) operator[]( std::size_t index ) const noexcept - requires( requires { m_ptr[std::size_t{ }]; } ) { + requires( requires { m_ptr[std::size_t{ }]; } ) + { return m_ptr[index]; } diff --git a/include/daw/daw_memory_mapped_file.h b/include/daw/daw_memory_mapped_file.h index cc6d53c64..394c08c9d 100644 --- a/include/daw/daw_memory_mapped_file.h +++ b/include/daw/daw_memory_mapped_file.h @@ -99,9 +99,12 @@ namespace daw::filesystem { m_fdata->size = static_cast( fsz ); } m_fdata->ptr = static_cast( - mmap( nullptr, m_fdata->size, + mmap( nullptr, + m_fdata->size, mode == open_mode::read ? PROT_READ : PROT_READ | PROT_WRITE, - MAP_SHARED, m_fdata->file, 0 ) ); + MAP_SHARED, + m_fdata->file, + 0 ) ); if( m_fdata->ptr == MAP_FAILED ) { m_fdata.reset( ); @@ -250,29 +253,37 @@ namespace daw::filesystem { m_fdata.emplace( ); { - HANDLE file_handle = ::CreateFileA( - file.data( ), mapfile_impl::CreateFileMode( mode ), 0, nullptr, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr ); + HANDLE file_handle = + ::CreateFileA( file.data( ), + mapfile_impl::CreateFileMode( mode ), + 0, + nullptr, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + nullptr ); if( file_handle == INVALID_HANDLE_VALUE ) { return false; } LARGE_INTEGER fsz; - if( not::GetFileSizeEx( file_handle, &fsz ) or fsz.QuadPart <= 0 ) { + if( not ::GetFileSizeEx( file_handle, &fsz ) or fsz.QuadPart <= 0 ) { m_fdata.reset( ); return false; } m_fdata->size = static_cast( fsz.QuadPart ); - m_fdata->handle = ::CreateFileMapping( - file_handle, nullptr, mapfile_impl::PageMode( mode ), fsz.u.HighPart, - fsz.u.LowPart, nullptr ); + m_fdata->handle = ::CreateFileMapping( file_handle, + nullptr, + mapfile_impl::PageMode( mode ), + fsz.u.HighPart, + fsz.u.LowPart, + nullptr ); if( m_fdata->handle == nullptr ) { m_fdata.reset( ); return false; } CloseHandle( file_handle ); } - auto ptr = MapViewOfFile( m_fdata->handle, mapfile_impl::MapMode( mode ), - 0, 0, 0 ); + auto ptr = MapViewOfFile( + m_fdata->handle, mapfile_impl::MapMode( mode ), 0, 0, 0 ); if( ptr == nullptr ) { m_fdata.reset( ); return false; @@ -287,29 +298,37 @@ namespace daw::filesystem { open_mode mode = open_mode::read ) noexcept { { - HANDLE file_handle = ::CreateFileW( - file.data( ), mapfile_impl::CreateFileMode( mode ), 0, nullptr, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr ); + HANDLE file_handle = + ::CreateFileW( file.data( ), + mapfile_impl::CreateFileMode( mode ), + 0, + nullptr, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + nullptr ); if( file_handle == INVALID_HANDLE_VALUE ) { return false; } LARGE_INTEGER fsz; - if( not::GetFileSizeEx( file_handle, &fsz ) or fsz.QuadPart <= 0 ) { + if( not ::GetFileSizeEx( file_handle, &fsz ) or fsz.QuadPart <= 0 ) { m_fdata.reset( ); return false; } m_fdata->size = static_cast( fsz.QuadPart ); - m_fdata->handle = ::CreateFileMapping( - file_handle, nullptr, mapfile_impl::PageMode( mode ), fsz.u.HighPart, - fsz.u.LowPart, nullptr ); + m_fdata->handle = ::CreateFileMapping( file_handle, + nullptr, + mapfile_impl::PageMode( mode ), + fsz.u.HighPart, + fsz.u.LowPart, + nullptr ); if( m_fdata->handle == nullptr ) { m_fdata.reset( ); return false; } CloseHandle( file_handle ); } - auto ptr = MapViewOfFile( m_fdata->handle, mapfile_impl::MapMode( mode ), - 0, 0, 0 ); + auto ptr = MapViewOfFile( + m_fdata->handle, mapfile_impl::MapMode( mode ), 0, 0, 0 ); if( ptr == nullptr ) { m_fdata.reset( ); return false; diff --git a/include/daw/daw_metro_hash.h b/include/daw/daw_metro_hash.h index 8c7df3b25..1d6ae9941 100644 --- a/include/daw/daw_metro_hash.h +++ b/include/daw/daw_metro_hash.h @@ -26,10 +26,10 @@ namespace daw::metro::metro_impl { daw::algorithm::do_n_arg( [&]( size_t n ) { // This is needed, the compiler must have it's unsigned char DAW_UNSAFE_BUFFER_FUNC_START - auto const tmp = static_cast(ptr[n]); + auto const tmp = static_cast( ptr[n] ); DAW_UNSAFE_BUFFER_FUNC_STOP - result = static_cast(result | static_cast(tmp) - << ( n * bit_count_v )); + result = static_cast( result | static_cast( tmp ) + << (n * bit_count_v)); } ); return result; } @@ -42,8 +42,8 @@ namespace daw::metro::metro_impl { static_assert( BitCount > 0 ); constexpr size_t size_bits = bit_count_v; return static_cast( - static_cast(value >> BitCount) | - static_cast(value << ( size_bits - BitCount ))); + static_cast( value >> BitCount ) | + static_cast( value << ( size_bits - BitCount ) ) ); } } // namespace daw::metro::metro_impl @@ -58,8 +58,8 @@ namespace daw::metro { constexpr uint64_t k3 = 0x30bc'5b29; uint64_t hash = ( seed + k2 ) * k0; - if(buff.size( ) >= 32U) { - uint64_t v[4]{hash, hash, hash, hash}; + if( buff.size( ) >= 32U ) { + uint64_t v[4]{ hash, hash, hash, hash }; do { v[0] += metro_impl::as_le_uint( buff.data( ) ) * k0; @@ -71,7 +71,7 @@ namespace daw::metro { v[3] += metro_impl::as_le_uint( buff.data( ) + 24 ) * k3; v[3] = metro_impl::rotr<29U>( v[3] ) + v[1]; buff.remove_prefix( 32U ); - } while(buff.size( ) >= 32); + } while( buff.size( ) >= 32 ); v[2] ^= metro_impl::rotr<37U>( ( ( v[0] + v[3] ) * k0 ) + v[1] ) * k1; v[3] ^= metro_impl::rotr<37U>( ( ( v[1] + v[2] ) * k1 ) + v[0] ) * k0; @@ -80,12 +80,12 @@ namespace daw::metro { hash += v[0] ^ v[1]; } - if(buff.size( ) >= 16) { + if( buff.size( ) >= 16 ) { uint64_t v0 = - hash + ( metro_impl::as_le_uint( buff.data( ) ) * k2 ); + hash + ( metro_impl::as_le_uint( buff.data( ) ) * k2 ); v0 = metro_impl::rotr<29U>( v0 ) * k3; uint64_t v1 = - hash + ( metro_impl::as_le_uint( buff.data( ) + 8 ) * k2 ); + hash + ( metro_impl::as_le_uint( buff.data( ) + 8 ) * k2 ); v1 = metro_impl::rotr<29U>( v1 ) * k3; v0 ^= metro_impl::rotr<21U>( v0 * k0 ) + v1; v1 ^= metro_impl::rotr<21U>( v1 * k3 ) + v0; @@ -93,30 +93,30 @@ namespace daw::metro { buff.remove_prefix( 16U ); } - if(buff.size( ) >= 8) { + if( buff.size( ) >= 8 ) { hash += metro_impl::as_le_uint( buff.data( ) ) * k3; hash ^= metro_impl::rotr<55U>( hash ) * k1; buff.remove_prefix( 8U ); } - if(buff.size( ) >= 4) { - hash += static_cast(static_cast( - metro_impl::as_le_uint( buff.data( ) ))) * - k3; + if( buff.size( ) >= 4 ) { + hash += static_cast( static_cast( + metro_impl::as_le_uint( buff.data( ) ) ) ) * + k3; hash ^= metro_impl::rotr<26U>( hash ) * k1; buff.remove_prefix( 4U ); } - if(buff.size( ) >= 2) { + if( buff.size( ) >= 2 ) { hash += static_cast( - metro_impl::as_le_uint( buff.data( ) )) * - k3; + metro_impl::as_le_uint( buff.data( ) ) ) * + k3; hash ^= metro_impl::rotr<48U>( hash ) * k1; buff.remove_prefix( 2U ); } - if(not buff.empty( )) { - hash += static_cast(buff.front( )) * k3; + if( not buff.empty( ) ) { + hash += static_cast( buff.front( ) ) * k3; hash ^= metro_impl::rotr<37U>( hash ) * k1; buff.remove_prefix( ); } diff --git a/include/daw/daw_min_perfect_hash.h b/include/daw/daw_min_perfect_hash.h index e5a9d0e69..dfb110ebf 100644 --- a/include/daw/daw_min_perfect_hash.h +++ b/include/daw/daw_min_perfect_hash.h @@ -157,7 +157,8 @@ namespace daw { static_assert( std::is_default_constructible_v ); - daw::algorithm::iota( buckets.begin( ), buckets.end( ), + daw::algorithm::iota( buckets.begin( ), + buckets.end( ), static_cast( 0 ), []( auto &i, size_type num ) { i.bucket_index = num; @@ -168,21 +169,22 @@ namespace daw { buckets[bucket].items.push_back( it ); } - daw::sort( buckets.begin( ), buckets.end( ), + daw::sort( buckets.begin( ), + buckets.end( ), []( auto const &lhs, auto const &rhs ) { return lhs.items.size( ) > rhs.items.size( ); } ); daw::array slots_claimed{ }; - daw::algorithm::find_if( buckets.cbegin( ), buckets.cend( ), - [&]( auto const &bucket ) { - if( bucket.items.empty( ) ) { - return true; - } - find_salt_for_bucket( bucket, slots_claimed ); - return false; - } ); + daw::algorithm::find_if( + buckets.cbegin( ), buckets.cend( ), [&]( auto const &bucket ) { + if( bucket.items.empty( ) ) { + return true; + } + find_salt_for_bucket( bucket, slots_claimed ); + return false; + } ); } explicit constexpr perfect_hash_table( @@ -284,14 +286,16 @@ namespace daw { daw::bounded_vector_t slots_this_bucket{ }; auto const success = daw::algorithm::all_of( - bucket.items.begin( ), bucket.items.end( ), + bucket.items.begin( ), + bucket.items.end( ), [&]( auto const *const item ) -> bool { hash_result const slot_wanted = scale_hash( call_hash( item->first, salt ) ); if( slots_claimed[slot_wanted] or - ( daw::algorithm::find( - slots_this_bucket.begin( ), slots_this_bucket.end( ), - slot_wanted ) != slots_this_bucket.end( ) ) ) { + ( daw::algorithm::find( slots_this_bucket.begin( ), + slots_this_bucket.end( ), + slot_wanted ) != + slots_this_bucket.end( ) ) ) { return false; } slots_this_bucket.push_back( slot_wanted ); diff --git a/include/daw/daw_move_only.h b/include/daw/daw_move_only.h index def3a5f87..5056c99cb 100644 --- a/include/daw/daw_move_only.h +++ b/include/daw/daw_move_only.h @@ -14,8 +14,8 @@ namespace daw { template - requires( not std::is_reference_v and - not std::is_pointer_v ) class move_only { + requires( not std::is_reference_v and not std::is_pointer_v ) + class move_only { T m_value; diff --git a/include/daw/daw_move_only_base.h b/include/daw/daw_move_only_base.h index 439148f71..58686e27e 100644 --- a/include/daw/daw_move_only_base.h +++ b/include/daw/daw_move_only_base.h @@ -18,6 +18,4 @@ namespace daw { move_only_base( move_only_base const & ) = delete; move_only_base &operator=( move_only_base const & ) = delete; }; -} - - +} // namespace daw diff --git a/include/daw/daw_mutable_function_ref.h b/include/daw/daw_mutable_function_ref.h index cad4f5ace..a54667213 100644 --- a/include/daw/daw_mutable_function_ref.h +++ b/include/daw/daw_mutable_function_ref.h @@ -96,17 +96,17 @@ namespace daw { Func, mutable_function_ref> and not std::is_const_v and mutable_function_ref_details::class_invocable_r ) // - constexpr mutable_function_ref( Func &func ) noexcept + Params...> ) + constexpr mutable_function_ref( Func &func ) noexcept : m_data( static_cast( std::addressof( func ) ) ) , m_thunk( obj_thunk ) {} template - requires( - mutable_function_ref_details::different_from - and mutable_function_ref_details::class_invocable_r< - Result, Func const &, Params...> ) // - constexpr mutable_function_ref( Func const &func ) noexcept + requires( mutable_function_ref_details::different_from< + Func, mutable_function_ref> and + mutable_function_ref_details::class_invocable_r< + Result, Func const &, Params...> ) + constexpr mutable_function_ref( Func const &func ) noexcept : m_data( static_cast( std::addressof( func ) ) ) , m_thunk( const_obj_thunk ) {} @@ -116,8 +116,8 @@ namespace daw { Func, mutable_function_ref> and not std::is_const_v and mutable_function_ref_details::class_invocable_r ) // - constexpr mutable_function_ref( Func &&func ) noexcept + Params...> ) + constexpr mutable_function_ref( Func &&func ) noexcept : m_data( static_cast( std::addressof( func ) ) ) , m_thunk( obj_thunk ) {} @@ -126,8 +126,8 @@ namespace daw { Func, mutable_function_ref> and not std::is_const_v and mutable_function_ref_details::class_invocable_r ) // - constexpr mutable_function_ref &operator=( Func &func ) noexcept { + Params...> ) + constexpr mutable_function_ref &operator=( Func &func ) noexcept { m_data = static_cast( std::addressof( func ) ); m_thunk = obj_thunk; return *this; @@ -135,10 +135,11 @@ namespace daw { template requires( - mutable_function_ref_details::different_from - and mutable_function_ref_details::class_invocable_r< - Result, Func const &, Params...> ) // - constexpr mutable_function_ref &operator=( Func const &func ) noexcept { + mutable_function_ref_details::different_from and + mutable_function_ref_details::class_invocable_r ) + constexpr mutable_function_ref &operator=( Func const &func ) noexcept { m_data = static_cast( std::addressof( func ) ); m_thunk = const_obj_thunk; return *this; @@ -210,17 +211,17 @@ namespace daw { Func, mutable_function_ref> and not std::is_const_v and mutable_function_ref_details::class_invocable_r ) // - constexpr mutable_function_ref( Func &func ) noexcept + Params...> ) + constexpr mutable_function_ref( Func &func ) noexcept : m_data( static_cast( std::addressof( func ) ) ) , m_thunk( obj_thunk ) {} template - requires( - mutable_function_ref_details::different_from - and mutable_function_ref_details::class_invocable_r ) // - constexpr mutable_function_ref( Func const &func ) noexcept + requires( mutable_function_ref_details::different_from< + Func, mutable_function_ref> and + mutable_function_ref_details::class_invocable_r< + void, Func const &, Params...> ) + constexpr mutable_function_ref( Func const &func ) noexcept : m_data( static_cast( std::addressof( func ) ) ) , m_thunk( const_obj_thunk ) {} @@ -230,18 +231,18 @@ namespace daw { Func, mutable_function_ref> and not std::is_const_v and mutable_function_ref_details::class_invocable_r ) // - constexpr mutable_function_ref( Func &&func ) noexcept + Params...> ) + constexpr mutable_function_ref( Func &&func ) noexcept : m_data( static_cast( std::addressof( func ) ) ) , m_thunk( obj_thunk ) {} template - requires( mutable_function_ref_details::different_from< - Func, mutable_function_ref> and - not std::is_const_v and - mutable_function_ref_details::class_invocable_r ) // - constexpr mutable_function_ref &operator=( Func &func ) noexcept { + requires( + mutable_function_ref_details::different_from and + not std::is_const_v and + mutable_function_ref_details::class_invocable_r ) + constexpr mutable_function_ref &operator=( Func &func ) noexcept { m_data = static_cast( std::addressof( func ) ); m_thunk = obj_thunk; return *this; @@ -249,10 +250,11 @@ namespace daw { template requires( - mutable_function_ref_details::different_from - and mutable_function_ref_details::class_invocable_r ) // - constexpr mutable_function_ref &operator=( Func const &func ) noexcept { + mutable_function_ref_details::different_from and + mutable_function_ref_details::class_invocable_r ) + constexpr mutable_function_ref &operator=( Func const &func ) noexcept { m_data = static_cast( std::addressof( func ) ); m_thunk = const_obj_thunk; return *this; diff --git a/include/daw/daw_named_params.h b/include/daw/daw_named_params.h index b1a188747..d1550f935 100644 --- a/include/daw/daw_named_params.h +++ b/include/daw/daw_named_params.h @@ -52,8 +52,8 @@ namespace daw::nparam { /// @param opts user set options /// @return The Option set in opts or def_value template - requires( Options ) constexpr auto get_opt( Option &&def_value, - Opts &&...vals ) { + requires( Options ) + constexpr auto get_opt( Option &&def_value, Opts &&...vals ) { if constexpr( sizeof...( Opts ) == 0 ) { // No replacements found return DAW_FWD( def_value ).value; diff --git a/include/daw/daw_nth_pack_element.h b/include/daw/daw_nth_pack_element.h index 88037480e..b7a0b142d 100644 --- a/include/daw/daw_nth_pack_element.h +++ b/include/daw/daw_nth_pack_element.h @@ -20,7 +20,8 @@ namespace daw { template DAW_ATTRIB_INLINE constexpr decltype( auto ) nth_pack_element_impl( std::index_sequence, Ts &&...values ) { - return []( ignore_constants_t..., auto &&nth, + return []( ignore_constants_t..., + auto &&nth, auto &&... ) -> decltype( nth ) && { return DAW_FWD( nth ); }( DAW_FWD( values )... ); diff --git a/include/daw/daw_observer_ptr.h b/include/daw/daw_observer_ptr.h index 117b897a3..cf3cd87c6 100644 --- a/include/daw/daw_observer_ptr.h +++ b/include/daw/daw_observer_ptr.h @@ -34,9 +34,8 @@ namespace daw { : m_ptr( p ) {} template - requires( not std::same_as and - std::convertible_to< - U *, T *> ) constexpr observer_ptr( observer_ptr other ) + requires( not std::same_as and std::convertible_to ) + constexpr observer_ptr( observer_ptr other ) : m_ptr( other.m_ptr ) {} constexpr observer_ptr &operator=( pointer p ) { @@ -132,10 +131,10 @@ namespace daw { }; template - requires std::is_array_v observer_ptr( A ) - -> observer_ptr>; + requires std::is_array_v + observer_ptr( A ) -> observer_ptr>; template - requires std::is_pointer_v

observer_ptr( P ) - -> observer_ptr>; + requires std::is_pointer_v

+ observer_ptr( P ) -> observer_ptr>; } // namespace daw diff --git a/include/daw/daw_parse_to.h b/include/daw/daw_parse_to.h index 4e5cf14c8..8675f2a45 100644 --- a/include/daw/daw_parse_to.h +++ b/include/daw/daw_parse_to.h @@ -116,8 +116,9 @@ namespace daw { return str; } - constexpr daw::string_view parse_to_value( daw::string_view str DAW_LIFETIME_BOUND, - tag_t ) { + constexpr daw::string_view + parse_to_value( daw::string_view str DAW_LIFETIME_BOUND, + tag_t ) { daw::exception::precondition_check( not str.empty( ) ); @@ -368,8 +369,9 @@ namespace daw { constexpr decltype( auto ) apply_string_impl( std::tuple, Callable &&callable, daw::string_view str, Splitter &&splitter ) { - return std::apply( DAW_FWD( callable ), parser::parse_to( - str, DAW_FWD( splitter ) ) ); + return std::apply( + DAW_FWD( callable ), + parser::parse_to( str, DAW_FWD( splitter ) ) ); } } // namespace impl @@ -391,8 +393,8 @@ namespace daw { Splitter &&splitter ) { using ftraits = typename daw::function_info>::decayed_args_tuple; - return impl::apply_string_impl( ftraits{ }, DAW_FWD( callable ), str, - DAW_FWD( splitter ) ); + return impl::apply_string_impl( + ftraits{ }, DAW_FWD( callable ), str, DAW_FWD( splitter ) ); } /// @brief Apply the reified string as the types deducted from the Callable @@ -407,8 +409,8 @@ namespace daw { constexpr decltype( auto ) apply_string2( Callable &&callable, daw::string_view str, daw::string_view delemiter ) { - return apply_string2( DAW_FWD( callable ), str, - parser::default_splitter{ delemiter } ); + return apply_string2( + DAW_FWD( callable ), str, parser::default_splitter{ delemiter } ); } /// @brief Apply the reified string as the types specified as Args... to the @@ -452,8 +454,8 @@ namespace daw { daw::string_view str, daw::string_view delemiter ) { - return apply_string( DAW_FWD( callable ), str, - parser::default_splitter{ delemiter } ); + return apply_string( + DAW_FWD( callable ), str, parser::default_splitter{ delemiter } ); } /// @brief Apply the reified string as the types specified as Arg to the @@ -474,8 +476,8 @@ namespace daw { constexpr decltype( auto ) apply_string( Callable &&callable, daw::string_view str ) { - return apply_string( DAW_FWD( callable ), str, - parser::default_splitter{ " " } ); + return apply_string( + DAW_FWD( callable ), str, parser::default_splitter{ " " } ); } namespace parse_to_impl { diff --git a/include/daw/daw_parser_addons.h b/include/daw/daw_parser_addons.h index 119e8f4f2..3e943f012 100644 --- a/include/daw/daw_parser_addons.h +++ b/include/daw/daw_parser_addons.h @@ -26,8 +26,8 @@ namespace daw::parser { bool has_decimal = false; auto const is_last = [&has_decimal]( auto const &v ) { - if(is_a( '.', v )) { - if(has_decimal) { + if( is_a( '.', v ) ) { + if( has_decimal ) { return true; } has_decimal = true; @@ -41,35 +41,33 @@ namespace daw::parser { template constexpr R from_num_char( char c ) { - auto r = static_cast(static_cast(c)) - static_cast< - unsigned>(static_cast('0')); - return static_cast(r); + auto r = static_cast( static_cast( c ) ) - + static_cast( static_cast( '0' ) ); + return static_cast( r ); } template constexpr void parse_unsigned_int( ForwardIterator first, ForwardIterator last, Result &result ) { - result = Result{}; + result = Result{ }; auto count = std::numeric_limits::digits10; daw::exception::precondition_check( - '-' != *first, - "Negative values are unsupported" ); + '-' != *first, "Negative values are unsupported" ); - for(; first != last and count > 0; ++first, --count) { - result *= Result{10}; + for( ; first != last and count > 0; ++first, --count ) { + result *= Result{ 10 }; Result const val = from_num_char( *first ); result += val; } daw::exception::precondition_check( - first == last, - "Not enough room to store number" ); + first == last, "Not enough room to store number" ); } template constexpr Result parse_unsigned_int( ForwardIterator first, ForwardIterator last ) { - Result result = Result{}; + Result result = Result{ }; parse_unsigned_int( first, last, result ); return result; } @@ -77,36 +75,35 @@ namespace daw::parser { template constexpr Result parse_unsigned_int( daw::not_null cstring ) { daw::not_null last = cstring; - while(*last) { + while( *last ) { ++last; } - Result result = Result{}; + Result result = Result{ }; parse_unsigned_int( cstring, last, result ); return result; } - template constexpr void parse_int( ForwardIterator first, ForwardIterator last, Result &result ) { bool is_neg = false; - if('-' == *first) { + if( '-' == *first ) { daw::exception::precondition_check( - std::numeric_limits::is_signed, - "Negative values are unsupported with unsigned Result" ); + std::numeric_limits::is_signed, + "Negative values are unsupported with unsigned Result" ); is_neg = true; ++first; } result = parse_unsigned_int( first, last ); - if(is_neg) { - result *= static_cast(-1); + if( is_neg ) { + result *= static_cast( -1 ); } } template constexpr Result parse_int( ForwardIterator first, ForwardIterator last ) { - Result result = Result{}; + Result result = Result{ }; parse_int( first, last, result ); return result; } @@ -118,14 +115,14 @@ namespace daw::parser { auto quote_char = *first; daw::exception::precondition_check( - is_quote( quote_char ) ); + is_quote( quote_char ) ); auto it = result.first; auto last_it = it; ++it; bool found = false; - while(it != last) { - if(( found = is_a( *it, quote_char ) ) and !is_escape( *last_it )) { + while( it != last ) { + if( ( found = is_a( *it, quote_char ) ) and !is_escape( *last_it ) ) { break; } last_it = it; diff --git a/include/daw/daw_parser_helper.h b/include/daw/daw_parser_helper.h index 812b88091..cdb7163d4 100644 --- a/include/daw/daw_parser_helper.h +++ b/include/daw/daw_parser_helper.h @@ -197,7 +197,8 @@ namespace daw::parser { [[nodiscard]] constexpr auto value_in( T &&value, Container &&container ) -> decltype( std::begin( container ) == std::end( container ) ) { - return std::find_if( std::begin( container ), std::end( container ), + return std::find_if( std::begin( container ), + std::end( container ), [&]( auto const &v ) { return is_a( value, v ); } ) == std::end( container ); @@ -268,8 +269,8 @@ namespace daw::parser { template constexpr void expect_true( T &&value, Predicate &&predicate, Predicates &&...predicates ) { - if( not is_true( DAW_FWD( value ), DAW_FWD( predicate ), - DAW_FWD( predicates )... ) ) { + if( not is_true( + DAW_FWD( value ), DAW_FWD( predicate ), DAW_FWD( predicates )... ) ) { daw::exception::daw_throw( ); } @@ -389,8 +390,8 @@ namespace daw::parser { until_value( first, last, DAW_FWD( divider ), DAW_FWD( dividers )... ); while( result ) { endings.push_back( result.last ); - result = until_value( result.last, last, DAW_FWD( divider ), - DAW_FWD( dividers )... ); + result = until_value( + result.last, last, DAW_FWD( divider ), DAW_FWD( dividers )... ); } if( result.first != result.last ) { endings.push_back( result.last ); @@ -521,7 +522,8 @@ namespace daw::parser { ForwardIterator last ) { auto start = trim_left( first, last ); auto finish = trim_right( start.first, last ); - return make_find_result( start.first, finish.last, + return make_find_result( start.first, + finish.last, static_cast( start ) or static_cast( finish ) ); } @@ -548,7 +550,8 @@ namespace daw::parser { } bool result = true; for( auto it = m_last_values.begin( ); - result and it != m_last_values.end( ); ++it ) { + result and it != m_last_values.end( ); + ++it ) { result = result and is_a( *( it ), '\r' ); ++it; result = result and is_a( *( it ), '\n' ); @@ -612,11 +615,13 @@ namespace daw::parser { operator( )( ForwardIterator first, ForwardIterator last ) const { auto result = make_find_result( first, last ); - auto pos = - std::search( result.first, result.last, m_to_match.begin( ), - m_to_match.end( ), []( auto const &lhs, auto const &rhs ) { - return is_a( lhs, rhs ); - } ); + auto pos = std::search( result.first, + result.last, + m_to_match.begin( ), + m_to_match.end( ), + []( auto const &lhs, auto const &rhs ) { + return is_a( lhs, rhs ); + } ); if( pos != result.last ) { result.last = pos; @@ -630,8 +635,8 @@ namespace daw::parser { [[nodiscard]] auto matcher( Container const &container ) { using value_t = daw::traits::root_type_t; std::vector values; - std::copy( container.begin( ), container.end( ), - std::back_inserter( values ) ); + std::copy( + container.begin( ), container.end( ), std::back_inserter( values ) ); return matcher_t{ std::move( values ) }; } diff --git a/include/daw/daw_pipelines.h b/include/daw/daw_pipelines.h index 732d041b6..742ae99a8 100644 --- a/include/daw/daw_pipelines.h +++ b/include/daw/daw_pipelines.h @@ -40,4 +40,4 @@ #include "daw/pipelines/to.h" #include "daw/pipelines/unique.h" #include "daw/pipelines/view.h" -#include "daw/pipelines/zip.h" +#include "daw/pipelines/zip.h" \ No newline at end of file diff --git a/include/daw/daw_poly_value.h b/include/daw/daw_poly_value.h index b02c55806..4c9511bb7 100644 --- a/include/daw/daw_poly_value.h +++ b/include/daw/daw_poly_value.h @@ -47,8 +47,8 @@ namespace daw { public: template - requires( not traits::is_first_type_v ) // - constexpr poly_value_storage( Args &&...args ) + requires( not traits::is_first_type_v ) + constexpr poly_value_storage( Args &&...args ) : m_value( DAW_FWD( args )... ) {} constexpr std::unique_ptr> @@ -73,9 +73,9 @@ namespace daw { }; template - requires std::is_base_of_v // - constexpr std::unique_ptr> - create( Args &&...args ) { + requires std::is_base_of_v + constexpr std::unique_ptr> + create( Args &&...args ) { return std::unique_ptr>( new poly_value_storage( DAW_FWD( args )... ) ); } @@ -93,18 +93,19 @@ namespace daw { m_storage{ }; public: - constexpr poly_value( ) requires( std::is_default_constructible_v ) + constexpr poly_value( ) + requires( std::is_default_constructible_v ) : m_storage( poly_value_impl::create( ) ) {} template - requires std::is_base_of_v> // - constexpr poly_value( T &&value ) + requires std::is_base_of_v> + constexpr poly_value( T &&value ) : m_storage( poly_value_impl::create>( DAW_FWD( value ) ) ) {} template - requires std::is_base_of_v> // - constexpr poly_value( construct_emplace_t, Args &&...args ) + requires std::is_base_of_v> + constexpr poly_value( construct_emplace_t, Args &&...args ) : m_storage( poly_value_impl::create>( DAW_FWD( args )... ) ) {} @@ -132,14 +133,14 @@ namespace daw { template requires( std::is_base_of_v and - not std::is_same_v ) // - poly_value( poly_value const &other ) + not std::is_same_v ) + poly_value( poly_value const &other ) : m_storage( other.m_storage->copy( ) ) {} template requires( std::is_base_of_v and - not std::is_same_v ) // - poly_value( poly_value &&other ) + not std::is_same_v ) + poly_value( poly_value &&other ) : m_storage( other.m_storage->move( ) ) {} Base const *get( ) const { diff --git a/include/daw/daw_print.h b/include/daw/daw_print.h index 2830d10dd..78252b12c 100644 --- a/include/daw/daw_print.h +++ b/include/daw/daw_print.h @@ -46,8 +46,8 @@ namespace daw { template DAW_ATTRIB_NOINLINE void println( FILE *f, std::format_string fmt, Args &&...args ) { - daw::print( f, "{}\n", - std::format( std::move( fmt ), DAW_FWD( args )... ) ); + daw::print( + f, "{}\n", std::format( std::move( fmt ), DAW_FWD( args )... ) ); } template @@ -60,8 +60,8 @@ namespace daw { template DAW_ATTRIB_NOINLINE void println( std::format_string fmt, Args &&...args ) { - daw::print( stdout, "{}\n", - std::format( std::move( fmt ), DAW_FWD( args )... ) ); + daw::print( + stdout, "{}\n", std::format( std::move( fmt ), DAW_FWD( args )... ) ); } template diff --git a/include/daw/daw_print_ostream.h b/include/daw/daw_print_ostream.h index 7af1d6783..5992f34f6 100644 --- a/include/daw/daw_print_ostream.h +++ b/include/daw/daw_print_ostream.h @@ -41,9 +41,10 @@ namespace daw { template std::ostream &print_log( std::format_string fmt, Args &&...args ) { - static_assert( ( has_std_formatter_specialization_v and ... ), - "print_log requires a std::formatter specialization for each " - "Arg type" ); + static_assert( + ( has_std_formatter_specialization_v and ... ), + "print_log requires a std::formatter specialization for each " + "Arg type" ); return daw::print( std::clog, "{}\n", std::format( std::move( fmt ), DAW_FWD( args )... ) ); } diff --git a/include/daw/daw_random.h b/include/daw/daw_random.h index 52d6eebf2..48710095f 100644 --- a/include/daw/daw_random.h +++ b/include/daw/daw_random.h @@ -102,8 +102,8 @@ namespace daw { Result result{ }; result.resize( count ); - random_fill( result.begin( ), - result.end( ), a, b ); + random_fill( + result.begin( ), result.end( ), a, b ); return result; } diff --git a/include/daw/daw_ref_storage.h b/include/daw/daw_ref_storage.h index 524996eda..8fe658ab8 100644 --- a/include/daw/daw_ref_storage.h +++ b/include/daw/daw_ref_storage.h @@ -53,18 +53,19 @@ namespace daw { static constexpr bool is_owned = not std::is_lvalue_reference_v; template - requires( can_store_v ) explicit constexpr ref_storage( U &&value ) + requires( can_store_v ) + explicit constexpr ref_storage( U &&value ) : m_storage( make_storage( DAW_FWD( value ) ) ) {} template requires( not std::is_lvalue_reference_v and - std::constructible_from ) // - explicit constexpr ref_storage( std::in_place_t, Args &&...args ) + std::constructible_from ) + explicit constexpr ref_storage( std::in_place_t, Args &&...args ) : m_storage( DAW_FWD( args )... ) {} template - requires( std::is_lvalue_reference_v and can_store_v ) // - explicit constexpr ref_storage( std::in_place_t, U &&value ) + requires( std::is_lvalue_reference_v and can_store_v ) + explicit constexpr ref_storage( std::in_place_t, U &&value ) : m_storage( make_storage( DAW_FWD( value ) ) ) {} [[nodiscard]] constexpr bool good( ) const noexcept { @@ -76,7 +77,8 @@ namespace daw { } [[nodiscard]] constexpr type get( ) && noexcept - requires( not std::is_lvalue_reference_v ) { + requires( not std::is_lvalue_reference_v ) + { return std::move( m_storage ); } @@ -111,7 +113,8 @@ namespace daw { } [[nodiscard]] constexpr bool operator==( ref_storage const &rhs ) const - requires( std::equality_comparable ) { + requires( std::equality_comparable ) + { if( not good( ) ) { return not rhs.good( ); } @@ -122,7 +125,8 @@ namespace daw { } [[nodiscard]] constexpr bool operator==( const_reference rhs ) const - requires( std::equality_comparable ) { + requires( std::equality_comparable ) + { if( not good( ) ) { return false; } diff --git a/include/daw/daw_safe_pointer.h b/include/daw/daw_safe_pointer.h index 053f82737..efc3a330f 100644 --- a/include/daw/daw_safe_pointer.h +++ b/include/daw/daw_safe_pointer.h @@ -295,8 +295,8 @@ namespace daw::memory { }; template - requires( - std::is_same_v, void> ) struct safe_pointer { + requires( std::is_same_v, void> ) + struct safe_pointer { using difference_type = std::ptrdiff_t; using size_type = std::size_t; using value_type = T; @@ -454,8 +454,8 @@ namespace std { } template - requires( std::is_constructible_v ) using rebind = - daw::memory::safe_pointer; + requires( std::is_constructible_v ) + using rebind = daw::memory::safe_pointer; static constexpr element_type *to_address( pointer p ) noexcept { return p.get( ); diff --git a/include/daw/daw_sbo.h b/include/daw/daw_sbo.h index 6c343de3b..842ad8ec4 100644 --- a/include/daw/daw_sbo.h +++ b/include/daw/daw_sbo.h @@ -97,8 +97,8 @@ namespace daw { // Store pointer from allocator in buffer new( &data ) base_type_ptr{ ptr }; // Construct new value from passed value at location from allocator - std::allocator_traits::construct( allocator, ptr, - DAW_FWD( value ) ); + std::allocator_traits::construct( + allocator, ptr, DAW_FWD( value ) ); engaged = engaged_types::allocated; return ptr; } diff --git a/include/daw/daw_shared_function.h b/include/daw/daw_shared_function.h index 1c16dc684..c514cb357 100644 --- a/include/daw/daw_shared_function.h +++ b/include/daw/daw_shared_function.h @@ -169,8 +169,8 @@ public: \ template - requires( std::is_class_v> ) // - constexpr auto make_fn_storage( Fn &&fn ) { + requires( std::is_class_v> ) + constexpr auto make_fn_storage( Fn &&fn ) { return new shared_function_storage, CVRef, IsNoExcept, @@ -180,8 +180,8 @@ public: \ template - requires( not std::is_class_v> ) // - constexpr auto make_fn_storage( Fn fn ) { + requires( not std::is_class_v> ) + constexpr auto make_fn_storage( Fn fn ) { if constexpr( std::is_pointer_v ) { if( not fn ) { return daw::null_v< @@ -250,9 +250,9 @@ public: \ public: template - requires( not std::is_same_v> ) // - explicit constexpr shared_function_base( Fn &&fn ) + requires( + not std::is_same_v> ) + explicit constexpr shared_function_base( Fn &&fn ) : m_storage( make_fn_storage( DAW_FWD( fn ) ) ) {} diff --git a/include/daw/daw_sort_n.h b/include/daw/daw_sort_n.h index 9ef215847..79f1daf71 100644 --- a/include/daw/daw_sort_n.h +++ b/include/daw/daw_sort_n.h @@ -621,8 +621,11 @@ namespace daw { m += delta; if( len >= 1000 ) { delta /= 2; - return sort_n_details::sort_5_impl( first, std::next( first, delta ), - m, std::next( m, delta ), lm1, + return sort_n_details::sort_5_impl( first, + std::next( first, delta ), + m, + std::next( m, delta ), + lm1, comp ); } return sort_n_details::sort_3_impl( first, m, lm1, comp ); @@ -704,8 +707,8 @@ namespace daw { if( swap_count == 0 ) { bool const fs = sort_n_details::insertion_sort_incomplete( first, i, comp ); - if( sort_n_details::insertion_sort_incomplete( std::next( i ), last, - comp ) ) { + if( sort_n_details::insertion_sort_incomplete( + std::next( i ), last, comp ) ) { if( fs ) { return; } @@ -760,8 +763,8 @@ namespace daw { ++counts[static_cast( ( *it ) % 10 )]; ++d; } - daw::algorithm::partial_sum( std::cbegin( counts ), std::cend( counts ), - std::begin( counts ) ); + daw::algorithm::partial_sum( + std::cbegin( counts ), std::cend( counts ), std::begin( counts ) ); if( is_ascend ) { while( first_in != last_in ) { diff --git a/include/daw/daw_span_writer.h b/include/daw/daw_span_writer.h index 6a41afba8..a5c51a6d0 100644 --- a/include/daw/daw_span_writer.h +++ b/include/daw/daw_span_writer.h @@ -49,10 +49,10 @@ namespace daw { /// The two ranges cannot overlap template requires( - std::ranges::contiguous_range - and daw::explicitly_convertible_to, T> ) - [[nodiscard]] constexpr std::span write_to_span( std::span out, - R const &r ) { + std::ranges::contiguous_range and + daw::explicitly_convertible_to, T> ) + [[nodiscard]] constexpr std::span write_to_span( std::span out, + R const &r ) { auto const sz = std::ranges::size( r ); daw_ensure( sz <= out.size( ) ); T *DAW_RESTRICT out_ptr = out.data( ); @@ -72,8 +72,8 @@ namespace daw { /// The two ranges cannot overlap and str must have a trailing 0 template requires( daw::explicitly_convertible_to ) - [[nodiscard]] constexpr std::span write_to_span_ntz( - std::span out, char const ( &str )[N] ) { + [[nodiscard]] constexpr std::span + write_to_span_ntz( std::span out, char const ( &str )[N] ) { daw_ensure( str[N - 1] == '\0' ); auto const sz = N - 1; daw_ensure( sz <= out.size( ) ); @@ -86,8 +86,8 @@ namespace daw { } template - requires( not std::is_const_v and not std::is_reference_v ) // - struct span_writer { + requires( not std::is_const_v and not std::is_reference_v ) + struct span_writer { using pointer = T *; using const_pointer = T const *; using reference = T &; @@ -183,9 +183,9 @@ namespace daw { template requires( - std::ranges::contiguous_range and daw::explicitly_convertible_to< - std::ranges::range_reference_t, T> ) // - constexpr span_writer &write( this auto &self, R const &r ) { + std::ranges::contiguous_range and + daw::explicitly_convertible_to, T> ) + constexpr span_writer &write( this auto &self, R const &r ) { auto const sz = std::ranges::size( r ); daw_ensure( sz <= self.m_size ); T *DAW_RESTRICT self_ptr = self.m_first; @@ -198,9 +198,9 @@ namespace daw { } template - requires( daw::explicitly_convertible_to ) // - constexpr span_writer &write_ntz( this auto &self, - char const ( &str )[N] ) { + requires( daw::explicitly_convertible_to ) + constexpr span_writer &write_ntz( this auto &self, + char const ( &str )[N] ) { daw_ensure( str[N - 1] == '\0' ); auto const sz = N - 1; daw_ensure( sz <= self.m_size ); diff --git a/include/daw/daw_stack_function.h b/include/daw/daw_stack_function.h index b8b025cd9..b0ac322d3 100644 --- a/include/daw/daw_stack_function.h +++ b/include/daw/daw_stack_function.h @@ -249,9 +249,10 @@ namespace daw { template decltype( auto ) store_if_not_empty( Func &&f ) { func_impl::validate_size ), MaxSize>( ); - return func_impl::store_if_not_empty, empty_child>( - DAW_FWD( f ) ); + return func_impl::store_if_not_empty, + empty_child>( DAW_FWD( f ) ); } public: diff --git a/include/daw/daw_tracked_allocator.h b/include/daw/daw_tracked_allocator.h index bd2e04c8d..d52508e0e 100644 --- a/include/daw/daw_tracked_allocator.h +++ b/include/daw/daw_tracked_allocator.h @@ -71,8 +71,8 @@ namespace daw::memory { constexpr void construct( pointer &ptr, Args &&...args ) noexcept( std::is_nothrow_constructible_v ) { DAW_SAFE_POINTER_ENSURE( ptr ); - std::allocator_traits::construct( alloc, ptr.get( ), - DAW_FWD( args )... ); + std::allocator_traits::construct( + alloc, ptr.get( ), DAW_FWD( args )... ); } constexpr void diff --git a/include/daw/daw_tuple.h b/include/daw/daw_tuple.h index 896d7485d..114670246 100644 --- a/include/daw/daw_tuple.h +++ b/include/daw/daw_tuple.h @@ -182,7 +182,8 @@ namespace daw { []( auto const &l, auto const &r ) { return l == r; }, - std::make_index_sequence{ }, rhs ); + std::make_index_sequence{ }, + rhs ); } else { return false; } @@ -196,7 +197,8 @@ namespace daw { []( auto const &l, auto const &r ) { return l != r; }, - std::make_index_sequence{ }, rhs ); + std::make_index_sequence{ }, + rhs ); } else { return true; } @@ -279,21 +281,24 @@ namespace daw { template inline constexpr decltype( auto ) apply( F &&f, tuple &t ) { return tuple_apply_detail::apply_impl( - DAW_FWD( f ), t, + DAW_FWD( f ), + t, std::make_index_sequence>>{ } ); } template inline constexpr decltype( auto ) apply( F &&f, tuple const &t ) { return tuple_apply_detail::apply_impl( - DAW_FWD( f ), t, + DAW_FWD( f ), + t, std::make_index_sequence>>{ } ); } template inline constexpr decltype( auto ) apply( F &&f, tuple &&t ) { return tuple_apply_detail::apply_impl( - DAW_FWD( f ), DAW_FWD( t ), + DAW_FWD( f ), + DAW_FWD( t ), std::make_index_sequence< std::tuple_size_v>>>{ } ); } @@ -301,7 +306,8 @@ namespace daw { template inline constexpr decltype( auto ) apply( F &&f, tuple const &&t ) { return tuple_apply_detail::apply_impl( - DAW_FWD( f ), DAW_FWD( t ), + DAW_FWD( f ), + DAW_FWD( t ), std::make_index_sequence< std::tuple_size_v>>>{ } ); } diff --git a/include/daw/daw_tuple2.h b/include/daw/daw_tuple2.h index c468b7098..54276c38d 100644 --- a/include/daw/daw_tuple2.h +++ b/include/daw/daw_tuple2.h @@ -189,7 +189,8 @@ namespace daw { constexpr std::size_t outter = location >> half_sz; constexpr std::size_t inner = ( location << half_sz ) >> half_sz; return daw::traits::identity>>>{ }; + inner, + daw::remove_cvref_t>>>{ }; } template using decode_get_type = @@ -236,14 +237,16 @@ namespace daw { inline constexpr decltype( auto ) apply( tuple2 const &tp, Func &&fn ) { return tuple2_impl::apply_impl( - tp, DAW_FWD( fn ), + tp, + DAW_FWD( fn ), std::make_index_sequence>>{ } ); } template inline constexpr decltype( auto ) apply( tuple2 &tp, Func &&fn ) { return tuple2_impl::apply_impl( - tp, DAW_FWD( fn ), + tp, + DAW_FWD( fn ), std::make_index_sequence>>{ } ); } @@ -251,14 +254,16 @@ namespace daw { inline constexpr decltype( auto ) apply( tuple2 const &&tp, Func &&fn ) { return tuple2_impl::apply_impl( - std::move( tp ), DAW_FWD( fn ), + std::move( tp ), + DAW_FWD( fn ), std::make_index_sequence>>{ } ); } template inline constexpr decltype( auto ) apply( tuple2 &&tp, Func &&fn ) { return tuple2_impl::apply_impl( - tp, std::move( fn ), + tp, + std::move( fn ), std::make_index_sequence>>{ } ); } } // namespace daw diff --git a/include/daw/daw_tuple_helper.h b/include/daw/daw_tuple_helper.h index 31d8bf69a..d40af14bf 100644 --- a/include/daw/daw_tuple_helper.h +++ b/include/daw/daw_tuple_helper.h @@ -135,14 +135,14 @@ namespace daw { template constexpr void for_each( std::tuple const &t1, F &&f ) { - tuple_details::for_each( t1, DAW_FWD( f ), - std::index_sequence_for{ } ); + tuple_details::for_each( + t1, DAW_FWD( f ), std::index_sequence_for{ } ); } template constexpr void apply( std::tuple &t1, F &&f ) { - tuple_details::for_each( t1, DAW_FWD( f ), - std::index_sequence_for{ } ); + tuple_details::for_each( + t1, DAW_FWD( f ), std::index_sequence_for{ } ); } namespace operators { @@ -151,8 +151,10 @@ namespace daw { typename F> constexpr bool apply_tuple( Result &&result, T1 &&op1, T2 &&op2, F &&f ) { - ::Unused( ( daw::invoke( DAW_FWD( f ), std::get( result ), - std::get( op1 ), std::get( op2 ) ), + ::Unused( ( daw::invoke( DAW_FWD( f ), + std::get( result ), + std::get( op1 ), + std::get( op2 ) ), 0 ) ); return true; } @@ -185,9 +187,10 @@ namespace daw { template constexpr bool apply_value2( Result &&result, T1 &&op1, T &&op2, F &&f ) { - ::Unused( ( daw::invoke( DAW_FWD( f ), std::get( result ), op1, - std::get( op2 ) ), - 0 ) ); + ::Unused( + ( daw::invoke( + DAW_FWD( f ), std::get( result ), op1, std::get( op2 ) ), + 0 ) ); return true; } @@ -211,8 +214,8 @@ namespace daw { constexpr std::tuple apply_tuple_value2( T const &op1, std::tuple const &op2, F f ) { std::tuple result; - apply_value2( result, op1, op2, f, - std::index_sequence_for{ } ); + apply_value2( + result, op1, op2, f, std::index_sequence_for{ } ); return result; } @@ -280,8 +283,8 @@ namespace daw { template constexpr std::tuple operator+( std::tuple const &lhs, std::tuple const &rhs ) { - return tuple_details::apply_tuple_tuple( lhs, rhs, - tuple_details::add_t::get( ) ); + return tuple_details::apply_tuple_tuple( + lhs, rhs, tuple_details::add_t::get( ) ); } template @@ -294,15 +297,15 @@ namespace daw { template constexpr std::tuple operator+( std::tuple const &lhs, T const &rhs ) { - return tuple_details::apply_tuple_value( lhs, rhs, - tuple_details::add_t::get( ) ); + return tuple_details::apply_tuple_value( + lhs, rhs, tuple_details::add_t::get( ) ); } template constexpr std::tuple operator-( std::tuple const &lhs, std::tuple const &rhs ) { - return tuple_details::apply_tuple_tuple( lhs, rhs, - tuple_details::sub_t::get( ) ); + return tuple_details::apply_tuple_tuple( + lhs, rhs, tuple_details::sub_t::get( ) ); } template @@ -315,15 +318,15 @@ namespace daw { template constexpr std::tuple operator-( std::tuple const &lhs, T const &rhs ) { - return tuple_details::apply_tuple_value( lhs, rhs, - tuple_details::sub_t::get( ) ); + return tuple_details::apply_tuple_value( + lhs, rhs, tuple_details::sub_t::get( ) ); } template constexpr std::tuple operator*( std::tuple const &lhs, std::tuple const &rhs ) { - return tuple_details::apply_tuple_tuple( lhs, rhs, - tuple_details::mul_t::get( ) ); + return tuple_details::apply_tuple_tuple( + lhs, rhs, tuple_details::mul_t::get( ) ); } template @@ -336,15 +339,15 @@ namespace daw { template constexpr std::tuple operator*( std::tuple const &lhs, T const &rhs ) { - return tuple_details::apply_tuple_value( lhs, rhs, - tuple_details::mul_t::get( ) ); + return tuple_details::apply_tuple_value( + lhs, rhs, tuple_details::mul_t::get( ) ); } template constexpr std::tuple operator/( std::tuple const &lhs, std::tuple const &rhs ) { - return tuple_details::apply_tuple_tuple( lhs, rhs, - tuple_details::div_t::get( ) ); + return tuple_details::apply_tuple_tuple( + lhs, rhs, tuple_details::div_t::get( ) ); } template @@ -357,8 +360,8 @@ namespace daw { template constexpr std::tuple operator/( std::tuple const &lhs, T const &rhs ) { - return tuple_details::apply_tuple_value( lhs, rhs, - tuple_details::div_t::get( ) ); + return tuple_details::apply_tuple_value( + lhs, rhs, tuple_details::div_t::get( ) ); } } // namespace operators @@ -439,7 +442,8 @@ namespace daw { template constexpr void apply_at( std::tuple const &tp, size_t index, Funcs &&...funcs ) { - tuple_details::apply_at_impl( tp, index, + tuple_details::apply_at_impl( tp, + index, daw::overload( DAW_FWD( funcs )... ), std::index_sequence_for{ } ); } @@ -447,7 +451,8 @@ namespace daw { template constexpr void apply_at( std::tuple &tp, size_t index, Funcs &&...funcs ) { - tuple_details::apply_at_impl( tp, index, + tuple_details::apply_at_impl( tp, + index, daw::overload( DAW_FWD( funcs )... ), std::index_sequence_for{ } ); } @@ -455,8 +460,8 @@ namespace daw { template constexpr void apply_at( std::tuple &&tp, size_t index, Funcs &&...funcs ) { - tuple_details::apply_at_impl( std::move( tp ), index, - daw::overload( DAW_FWD( funcs )... ) ); + tuple_details::apply_at_impl( + std::move( tp ), index, daw::overload( DAW_FWD( funcs )... ) ); } namespace tuple_details { @@ -507,7 +512,8 @@ namespace daw { template constexpr auto forward_nontemp_as_tuple( Ts &&...values ) { using tuple_t = std::tuple, - daw::remove_cvref_t, Ts>...>; + daw::remove_cvref_t, + Ts>...>; return tuple_t{ DAW_FWD( values )... }; } } // namespace daw diff --git a/include/daw/daw_utility.h b/include/daw/daw_utility.h index 4f1992f4a..4d56036b1 100644 --- a/include/daw/daw_utility.h +++ b/include/daw/daw_utility.h @@ -291,8 +291,8 @@ namespace daw { template [[nodiscard]] auto find_all_where( T const &values, Pred predicate ) { - return find_all_where( std::cbegin( values ), std::cend( values ), - predicate ); + return find_all_where( + std::cbegin( values ), std::cend( values ), predicate ); } [[nodiscard]] constexpr char AsciiUpper( char chr ) noexcept { @@ -314,20 +314,20 @@ namespace daw { template [[nodiscard]] constexpr auto AsciiUpper( std::basic_string str ) noexcept { - daw::algorithm::map( str.cbegin( ), str.cend( ), str.begin( ), - []( CharType c ) noexcept { - return AsciiUpper( c ); - } ); + daw::algorithm::map( + str.cbegin( ), str.cend( ), str.begin( ), []( CharType c ) noexcept { + return AsciiUpper( c ); + } ); return std::move( str ); } template [[nodiscard]] constexpr auto AsciiLower( std::basic_string str ) noexcept { - daw::algorithm::map( str.cbegin( ), str.cend( ), str.begin( ), - []( CharType c ) noexcept { - return AsciiLower( c ); - } ); + daw::algorithm::map( + str.cbegin( ), str.cend( ), str.begin( ), []( CharType c ) noexcept { + return AsciiLower( c ); + } ); return std::move( str ); } @@ -385,8 +385,8 @@ namespace daw { template [[nodiscard]] constexpr auto index_of( Container const &container, Item const &item ) noexcept { - auto const pos = daw::algorithm::find( std::begin( container ), - std::end( container ), item ); + auto const pos = daw::algorithm::find( + std::begin( container ), std::end( container ), item ); return std::distance( std::begin( container ), pos ); } @@ -911,8 +911,8 @@ namespace daw { template constexpr void pack_apply( std::size_t N, Function &&func, Args &&...args ) { - utility_details::utility_details<0>( N, DAW_FWD( func ), - DAW_FWD( args )... ); + utility_details::utility_details<0>( + N, DAW_FWD( func ), DAW_FWD( args )... ); } template @@ -954,5 +954,5 @@ namespace daw { } template - inline constexpr T * null_v = static_cast( nullptr ); + inline constexpr T *null_v = static_cast( nullptr ); } // namespace daw diff --git a/include/daw/daw_visit.h b/include/daw/daw_visit.h index 93b3acace..2962943d3 100644 --- a/include/daw/daw_visit.h +++ b/include/daw/daw_visit.h @@ -10,9 +10,9 @@ #include "ciso646.h" #include "cpp_17.h" +#include "daw/daw_check_exceptions.h" #include "daw_assume.h" #include "daw_attributes.h" -#include "daw/daw_check_exceptions.h" #include "daw_consteval.h" #include "daw_likely.h" #include "daw_move.h" @@ -85,18 +85,20 @@ namespace daw { return v.index( ); } - DAW_MAKE_REQ_TRAIT( has_variant_npos, T::variant_npos ); - - template, std::nullptr_t> = nullptr> - DAW_ATTRIB_FLATINLINE constexpr bool is_empty( Variant const & v ) { - return v.index( ) == Variant::variant_npos; + DAW_MAKE_REQ_TRAIT( has_variant_npos, T::variant_npos ); + + template, + std::nullptr_t> = nullptr> + DAW_ATTRIB_FLATINLINE constexpr bool is_empty( Variant const &v ) { + return v.index( ) == Variant::variant_npos; } - template, std::nullptr_t> = nullptr> - DAW_ATTRIB_INLINE constexpr bool is_empty( Variant const & ) { - return false; + template, + std::nullptr_t> = nullptr> + DAW_ATTRIB_INLINE constexpr bool is_empty( Variant const & ) { + return false; } - + template struct get_var_size; @@ -138,8 +140,9 @@ namespace daw { return DAW_FWD( vis )( get_nt( DAW_FWD( var ) ) ) template - DAW_ATTRIB_FLATINLINE [[nodiscard]] inline constexpr R - visit_nt( Variant &&var, Visitor &&vis ) { + DAW_ATTRIB_FLATINLINE + [[nodiscard]] inline constexpr R visit_nt( Variant &&var, + Visitor &&vis ) { constexpr std::size_t VSz = get_var_size_v; if constexpr( VSz - N >= 16 ) { switch( get_index( var ) ) { @@ -389,7 +392,7 @@ namespace daw { DAW_FWD( visitors )... )( get_nt<0>( DAW_FWD( var ) ) ) ); if( DAW_UNLIKELY( visit_details::is_empty( var ) ) ) { - DAW_UNLIKELY_BRANCH + DAW_UNLIKELY_BRANCH visit_details::visit_error( ); } return daw::visit_details::visit_nt<0, result_t>( diff --git a/include/daw/daw_visit_as.h b/include/daw/daw_visit_as.h index 0dbd83ec7..3a9294d6c 100644 --- a/include/daw/daw_visit_as.h +++ b/include/daw/daw_visit_as.h @@ -13,7 +13,6 @@ #include - #if defined( DAW_CX_BIT_CAST ) #define DAW_CX_IF_BIT_CAST constexpr #else @@ -22,29 +21,31 @@ namespace daw { /** - * @brief Invokes a visitor on a reinterpretation of the provided value, allowing - * modification of the value via the provided visitor, and optionally + * @brief Invokes a visitor on a reinterpretation of the provided value, + * allowing modification of the value via the provided visitor, and optionally * returning a value from the visitor's result. * - * @tparam VisitedT The type to reinterpreted `value` as when invoking the visitor. + * @tparam VisitedT The type to reinterpreted `value` as when invoking the + * visitor. * @tparam OrigT The original type of the `value` being modified or accessed. * @tparam Visitor The invocable type that will be applied to the value. * - * @param value A reference to the value being visited and potentially modified. + * @param value A reference to the value being visited and potentially + * modified. * @param visitor A invocable that processes the value once reinterpreted as * type `VisitedT`. * - * @return The result of invoking the visitor if the visitor returns a non-void - * value; otherwise, nothing is returned. + * @return The result of invoking the visitor if the visitor returns a + * non-void value; otherwise, nothing is returned. * * @details The function performs a bit cast to reinterpret `value` as type - * `VisitedT`. It then applies the visitor to this reinterpreted value. - * After the visitor processes the value, the function updates the + * `VisitedT`. It then applies the visitor to this reinterpreted + * value. After the visitor processes the value, the function updates the * original value with the potentially modified value. If the visitor * returns a result, it is also returned by this function. */ template -DAW_CX_IF_BIT_CAST auto visit_as( OrigT &value, Visitor &&visitor ) { + DAW_CX_IF_BIT_CAST auto visit_as( OrigT &value, Visitor &&visitor ) { auto tmp = daw::bit_cast( value ); if constexpr( std::is_void_v> ) { std::invoke( DAW_FWD( visitor ), tmp ); @@ -56,22 +57,24 @@ DAW_CX_IF_BIT_CAST auto visit_as( OrigT &value, Visitor &&visitor ) { } } - /** * @brief Invokes a visitor on a reinterpretation of the provided value. * - * @tparam VisitedT The type to reinterpret `value` as when invoking the visitor. + * @tparam VisitedT The type to reinterpret `value` as when invoking the + * visitor. * @tparam OrigT The original type of the `value`. - * @tparam Visitor The callable type that will be applied to the reinterpreted value. + * @tparam Visitor The callable type that will be applied to the reinterpreted + * value. * - * @param value A constant reference to the value being reinterpreted and visited. + * @param value A constant reference to the value being reinterpreted and + * visited. * @param visitor A callable object that operates on the reinterpreted value. * * @return The result of invoking the visitor with the reinterpreted value. * - * @details This function performs a bit-cast of `value` to the type `VisitedT` and - * then applies the visitor to the reinterpreted value. The result of the - * visitor is returned if it produces a value. + * @details This function performs a bit-cast of `value` to the type + * `VisitedT` and then applies the visitor to the reinterpreted value. The + * result of the visitor is returned if it produces a value. */ template DAW_CX_IF_BIT_CAST auto visit_as( OrigT const &value, Visitor &&visitor ) { diff --git a/include/daw/deprecated/daw_bounded_string.h b/include/daw/deprecated/daw_bounded_string.h index 4c7f00a34..7f7c46e2e 100644 --- a/include/daw/deprecated/daw_bounded_string.h +++ b/include/daw/deprecated/daw_bounded_string.h @@ -367,24 +367,24 @@ namespace daw { static constexpr int compare( basic_bounded_string const &lhs, basic_bounded_string const &rhs ) noexcept { - auto const str_compare = []( CharT const *p0, CharT const *p1, - size_t len ) { - auto const last = p0 + len; - while( p0 != last ) { - if( *p0 != *p1 ) { - if( *p0 < *p1 ) { - return -1; - } - return 1; - } - ++p0; - ++p1; - } - return 0; - }; - - auto cmp = str_compare( lhs.data( ), rhs.data( ), - (daw::min)( lhs.size( ), rhs.size( ) ) ); + auto const str_compare = + []( CharT const *p0, CharT const *p1, size_t len ) { + auto const last = p0 + len; + while( p0 != last ) { + if( *p0 != *p1 ) { + if( *p0 < *p1 ) { + return -1; + } + return 1; + } + ++p0; + ++p1; + } + return 0; + }; + + auto cmp = str_compare( + lhs.data( ), rhs.data( ), (daw::min)( lhs.size( ), rhs.size( ) ) ); if( cmp == 0 ) { if( lhs.size( ) < rhs.size( ) ) { return -1; @@ -400,24 +400,24 @@ namespace daw { static constexpr int compare( basic_bounded_string const &lhs, CharT const *rhs_ptr, size_t rhs_size ) noexcept { - auto const str_compare = []( CharT const *p0, CharT const *p1, - size_t len ) { - auto const last = p0 + len; - while( p0 != last ) { - if( *p0 != *p1 ) { - if( *p0 < *p1 ) { - return -1; - } - return 1; - } - ++p0; - ++p1; - } - return 0; - }; - - auto cmp = str_compare( lhs.data( ), rhs_ptr, - (daw::min)( lhs.size( ), rhs_size ) ); + auto const str_compare = + []( CharT const *p0, CharT const *p1, size_t len ) { + auto const last = p0 + len; + while( p0 != last ) { + if( *p0 != *p1 ) { + if( *p0 < *p1 ) { + return -1; + } + return 1; + } + ++p0; + ++p1; + } + return 0; + }; + + auto cmp = str_compare( + lhs.data( ), rhs_ptr, (daw::min)( lhs.size( ), rhs_size ) ); if( cmp == 0 ) { if( lhs.size( ) < rhs_size ) { return -1; diff --git a/include/daw/deprecated/daw_checked_expected.h b/include/daw/deprecated/daw_checked_expected.h index 527f93721..c177d952a 100644 --- a/include/daw/deprecated/daw_checked_expected.h +++ b/include/daw/deprecated/daw_checked_expected.h @@ -127,8 +127,7 @@ namespace daw { // template>> - template, std::nullptr_t> = nullptr> static checked_expected_t from_code( Function func, Args &&...args ) { @@ -311,8 +310,8 @@ namespace daw { // std::enable_if_t>> template - static checked_expected_t - from_code( Function func, Arg &&arg, Args &&...args ) { + static checked_expected_t from_code( Function func, Arg &&arg, + Args &&...args ) { try { func( DAW_FWD( arg ), DAW_FWD( args )... ); return checked_expected_t{ true }; @@ -330,8 +329,7 @@ namespace daw { // template>> - template( )( std::declval( )... ) )> checked_expected_t( Function func, Args &&...args ) diff --git a/include/daw/deprecated/daw_cstring.h b/include/daw/deprecated/daw_cstring.h index 35bdc2e61..e11e77d87 100644 --- a/include/daw/deprecated/daw_cstring.h +++ b/include/daw/deprecated/daw_cstring.h @@ -38,16 +38,14 @@ namespace daw { struct no_copy_t {}; - [[deprecated]] constexpr CString( CharT const *ptr, - no_copy_t, + [[deprecated]] constexpr CString( CharT const *ptr, no_copy_t, size_t const length ) noexcept : m_data{ ptr } , m_size{ 0 == length ? string_length( ptr ) : length } , m_local_string{ false } {} public: - [[deprecated]] constexpr CString( CharT const *ptr, - bool do_copy, + [[deprecated]] constexpr CString( CharT const *ptr, bool do_copy, size_t const length ) : m_data{ ptr } , m_size{ 0 == length ? string_length( ptr ) : length } diff --git a/include/daw/deprecated/daw_fixed_array.h b/include/daw/deprecated/daw_fixed_array.h index 0177587d7..2bd8b5219 100644 --- a/include/daw/deprecated/daw_fixed_array.h +++ b/include/daw/deprecated/daw_fixed_array.h @@ -124,13 +124,11 @@ namespace daw { std::copy_n( first, m_size, m_data ); } - template< - typename IteratorF, - typename IteratorL, - std::enable_if_t< - (daw::traits::has_subtraction_operator_v and - daw::traits::is_iterator_v), - std::nullptr_t> = nullptr> + template and + daw::traits::is_iterator_v), + std::nullptr_t> = nullptr> fixed_array( IteratorF first, IteratorL last ) : m_size( static_cast( last - first ) ) , m_data( new value_type[m_size] ) { @@ -217,8 +215,8 @@ namespace daw { fixed_array( std::in_place_type_t, Ts... ) -> fixed_array; template - fixed_array( std::in_place_t, - Ts... ) -> fixed_array>; + fixed_array( std::in_place_t, Ts... ) + -> fixed_array>; template fixed_array( std::size_t, T ) -> fixed_array; diff --git a/include/daw/deprecated/daw_heap_value.h b/include/daw/deprecated/daw_heap_value.h index 1044e4f90..89a2d0dbd 100644 --- a/include/daw/deprecated/daw_heap_value.h +++ b/include/daw/deprecated/daw_heap_value.h @@ -47,9 +47,8 @@ namespace daw { } // Make this less perfect so that we can still do copy/move construction - template< - typename Arg, - typename = std::enable_if_t( )>> + template( )>> heap_value( Arg &&arg ) : m_value{ std::make_unique( DAW_FWD( arg ) ) } {} diff --git a/include/daw/deprecated/daw_optional_poly.h b/include/daw/deprecated/daw_optional_poly.h index 0b3e99772..1750ac0a7 100644 --- a/include/daw/deprecated/daw_optional_poly.h +++ b/include/daw/deprecated/daw_optional_poly.h @@ -30,10 +30,9 @@ namespace daw { private: std::unique_ptr m_value; - template< - typename T, - typename = std::enable_if_t::value or - std::is_same::value>> + template::value or + std::is_same::value>> constexpr static T *make_copy( T *ptr ) { if( !ptr ) { return nullptr; @@ -64,38 +63,33 @@ namespace daw { m_value.reset( new value_type{ DAW_FWD( args )... } ); } - template< - typename T, - typename = std::enable_if_t::value or - std::is_same::value>> + template::value or + std::is_same::value>> optional_poly( T &&value ) : m_value{ new std::decay_t{ DAW_FWD( value ) } } {} - template< - typename T, - typename = std::enable_if_t::value or - std::is_same::value>> + template::value or + std::is_same::value>> optional_poly( T const &value ) : m_value{ new std::decay_t{ value } } {} - template< - typename T, - typename = std::enable_if_t::value or - std::is_same::value>> + template::value or + std::is_same::value>> explicit optional_poly( optional_poly const &other ) : m_value{ make_copy( other.m_value.get( ) ) } {} - template< - typename T, - typename = std::enable_if_t::value or - std::is_same::value>> + template::value or + std::is_same::value>> explicit optional_poly( optional_poly &&other ) noexcept : m_value{ other.m_value.release( ) } {} - template< - typename T, - typename = std::enable_if_t::value or - std::is_same::value>> + template::value or + std::is_same::value>> optional_poly &operator=( optional_poly const &rhs ) { m_value.reset( make_copy( rhs.m_value.get( ) ) ); return *this; diff --git a/include/daw/deprecated/daw_ordered_map.h b/include/daw/deprecated/daw_ordered_map.h index 41071a137..204d631ef 100644 --- a/include/daw/deprecated/daw_ordered_map.h +++ b/include/daw/deprecated/daw_ordered_map.h @@ -83,9 +83,7 @@ namespace daw { } } // namespace ordered_map_impl // Use linear searching for key, keep values in insertion order - template, + template, typename Allocator = std::allocator>, typename Container = std::vector, Allocator>> struct ordered_map { @@ -231,8 +229,7 @@ namespace daw { , m_compare( comp ) {} template - constexpr ordered_map( InputIterator first, - InputIterator last, + constexpr ordered_map( InputIterator first, InputIterator last, key_compare const &comp = key_compare{ }, allocator_type const &alloc = allocator_type{ } ) : m_compare( comp ) @@ -247,8 +244,7 @@ namespace daw { } template - constexpr ordered_map( InputIterator first, - InputIterator last, + constexpr ordered_map( InputIterator first, InputIterator last, allocator_type const &alloc = allocator_type{ } ) : m_values( alloc ) { @@ -302,9 +298,8 @@ namespace daw { } */ - template< - typename P, - daw::enable_when_t> = nullptr> + template> = nullptr> constexpr std::pair insert( P &&value ) { auto pos = find( std::get<0>( value ) ); if( pos == end( ) ) { diff --git a/include/daw/deprecated/daw_range_algorithm.h b/include/daw/deprecated/daw_range_algorithm.h index f9df11e5d..2de377952 100644 --- a/include/daw/deprecated/daw_range_algorithm.h +++ b/include/daw/deprecated/daw_range_algorithm.h @@ -30,8 +30,7 @@ namespace daw::algorithm { return container; } - template, std::nullptr_t> = nullptr> Container &sort( Container &container, Compare compare ) noexcept( noexcept( @@ -58,13 +57,11 @@ namespace daw::algorithm { return container; } - template, std::nullptr_t> = nullptr> Container &stable_sort( Container &container, Compare compare ) noexcept( - noexcept( std::stable_sort( std::begin( container ), - std::end( container ), + noexcept( std::stable_sort( std::begin( container ), std::end( container ), compare ) ) ) { static_assert( @@ -79,19 +76,17 @@ namespace daw::algorithm { return container; } - template, std::nullptr_t> = nullptr> - decltype( auto ) - find( Container &container, Value const &value ) noexcept( noexcept( - std::find( std::begin( container ), std::end( container ), value ) ) ) { + decltype( auto ) find( Container &container, Value const &value ) noexcept( + noexcept( std::find( std::begin( container ), std::end( container ), + value ) ) ) { return std::find( std::begin( container ), std::end( container ), value ); } - template, std::nullptr_t> = nullptr> decltype( auto ) @@ -101,8 +96,7 @@ namespace daw::algorithm { return std::find( std::begin( container ), std::end( container ), value ); } - template, std::nullptr_t> = nullptr> decltype( auto ) @@ -119,8 +113,7 @@ namespace daw::algorithm { return std::find_if( std::begin( container ), std::end( container ), pred ); } - template, std::nullptr_t> = nullptr> decltype( auto ) @@ -175,20 +168,17 @@ namespace daw::algorithm { std::begin( container ), std::end( container ), std::move( init ) ); } - template>, std::nullptr_t> = nullptr> - constexpr T - accumulate( Container const &container, T init, BinaryOperator oper ) { + constexpr T accumulate( Container const &container, T init, + BinaryOperator oper ) { return daw::algorithm::accumulate( std::begin( container ), std::end( container ), std::move( init ), oper ); } - template, std::nullptr_t> = nullptr> auto map( Container const &container, UnaryOperator unary_operator ) { @@ -208,13 +198,10 @@ namespace daw::algorithm { return result; } - template, std::nullptr_t> = nullptr> - void map( Container const &container, - OutputIterator &first_out, + void map( Container const &container, OutputIterator &first_out, UnaryOperator unary_operator ) noexcept( noexcept( std:: transform( @@ -238,13 +225,10 @@ namespace daw::algorithm { unary_operator ); } - template, std::nullptr_t> = nullptr> - void map( Container const &container, - OutputIterator &&first_out, + void map( Container const &container, OutputIterator &&first_out, UnaryOperator unary_operator ) noexcept( noexcept( std:: transform( @@ -264,8 +248,7 @@ namespace daw::algorithm { } // max_element - template, std::nullptr_t> = nullptr> decltype( auto ) max_element( Container &container ) noexcept( noexcept( @@ -274,9 +257,7 @@ namespace daw::algorithm { return std::max_element( std::cbegin( container ), std::cend( container ) ); } - template, std::nullptr_t> = nullptr> decltype( auto ) max_element( Container const &container ) noexcept( noexcept( @@ -285,14 +266,12 @@ namespace daw::algorithm { return std::max_element( std::cbegin( container ), std::cend( container ) ); } - template, std::nullptr_t> = nullptr> decltype( auto ) max_element( Container &container, Compare compare ) noexcept( - noexcept( std::max_element( std::begin( container ), - std::end( container ), + noexcept( std::max_element( std::begin( container ), std::end( container ), compare ) ) ) { static_assert( @@ -307,14 +286,12 @@ namespace daw::algorithm { std::begin( container ), std::end( container ), compare ); } - template, std::nullptr_t> = nullptr> decltype( auto ) max_element( Container const &container, Compare compare ) noexcept( - noexcept( std::max_element( std::begin( container ), - std::end( container ), + noexcept( std::max_element( std::begin( container ), std::end( container ), compare ) ) ) { static_assert( @@ -337,8 +314,7 @@ namespace daw::algorithm { } template - bool contains( Container const &container, - Value const &value, + bool contains( Container const &container, Value const &value, UnaryPredicate pred ) { auto pred2 = [&value, &pred]( Value const &val ) { return pred( value, val ); @@ -362,8 +338,8 @@ namespace daw::algorithm { } template - auto - where( InputIterator first, InputIterator last, UnaryPredicate predicate ) { + auto where( InputIterator first, InputIterator last, + UnaryPredicate predicate ) { auto rng = make_range( first, last ); return where( rng, predicate ); } diff --git a/include/daw/deprecated/daw_range_collection.h b/include/daw/deprecated/daw_range_collection.h index 7a3de514c..b2261b5e2 100644 --- a/include/daw/deprecated/daw_range_collection.h +++ b/include/daw/deprecated/daw_range_collection.h @@ -451,8 +451,7 @@ namespace daw { std::false_type( ), DAW_FWD( arg ), DAW_FWD( args )... ); } - template, std::nullptr_t> = nullptr> OStream &operator<<( OStream &os, CollectionRange const &rng ) { diff --git a/include/daw/deprecated/daw_range_operators.h b/include/daw/deprecated/daw_range_operators.h index cbe65b12f..65f1bfc18 100644 --- a/include/daw/deprecated/daw_range_operators.h +++ b/include/daw/deprecated/daw_range_operators.h @@ -55,8 +55,7 @@ namespace daw { std::tuple clause_name##_args; \ \ template< \ - typename Container, \ - typename... ClauseArgs, \ + typename Container, typename... ClauseArgs, \ typename std::enable_if_t, \ !daw::range::is_range_collection_v>> * = nullptr, \ @@ -68,8 +67,7 @@ namespace daw { } \ \ template< \ - typename Container, \ - typename... ClauseArgs, \ + typename Container, typename... ClauseArgs, \ typename std::enable_if_t< \ daw::range::is_range_reference_v> * = nullptr> \ static auto clause_name##_helper( Container container, \ @@ -78,8 +76,7 @@ namespace daw { } \ \ template< \ - typename Container, \ - typename... ClauseArgs, \ + typename Container, typename... ClauseArgs, \ typename std::enable_if_t< \ daw::range::is_range_collection_v> * = nullptr> \ static auto clause_name##_helper( Container const &container, \ @@ -111,7 +108,7 @@ namespace daw { \ public: \ clause_name##_t( std::tuple &&args ) \ - : clause_name##_args( std::move( args ) ) {} \ + : clause_name##_args( std::move( args ) ) {} \ \ template \ auto operator( )( Container &&container ) const { \ diff --git a/include/daw/deprecated/daw_range_parallel_operators.h b/include/daw/deprecated/daw_range_parallel_operators.h index 9fb178316..4551f7392 100644 --- a/include/daw/deprecated/daw_range_parallel_operators.h +++ b/include/daw/deprecated/daw_range_parallel_operators.h @@ -41,9 +41,9 @@ namespace daw { typedef seq type; }; } // namespace details - } // namespace operators - } // namespace parallel - } // namespace range + } // namespace operators + } // namespace parallel + } // namespace range } // namespace daw #define DAW_PARALLEL_RANGE_GENERATE_VCLAUSE( clause_name ) \ @@ -57,38 +57,35 @@ namespace daw { std::tuple clause_name##_args; \ \ template< \ - typename Container, \ - typename... ClauseArgs, \ + typename Container, typename... ClauseArgs, \ typename std::enable_if_t, \ daw::range::is_range_collection>> * = nullptr, \ typename = void> \ static auto \ - clause_name##_helper( Container const &container, \ - ClauseArgs &&...clause_args ) { \ + clause_name##_helper( Container const &container, \ + ClauseArgs &&...clause_args ) { \ return from( container ) \ .clause_name( DAW_FWD( clause_args )... ); \ } \ \ template< \ - typename Container, \ - typename... ClauseArgs, \ + typename Container, typename... ClauseArgs, \ typename std::enable_if_t< \ daw::range::is_range_reference_v> * = nullptr> \ static auto \ - clause_name##_helper( Container container, \ - ClauseArgs &&...clause_args ) { \ + clause_name##_helper( Container container, \ + ClauseArgs &&...clause_args ) { \ return container.clause_name( DAW_FWD( clause_args )... ); \ } \ \ template< \ - typename Container, \ - typename... ClauseArgs, \ + typename Container, typename... ClauseArgs, \ typename std::enable_if_t< \ daw::range::is_range_collection_v> * = nullptr> \ static auto \ - clause_name##_helper( Container const &container, \ - ClauseArgs &&...clause_args ) { \ + clause_name##_helper( Container const &container, \ + ClauseArgs &&...clause_args ) { \ return container.clause_name( DAW_FWD( clause_args )... ); \ } \ \ diff --git a/include/daw/deprecated/daw_range_reference.h b/include/daw/deprecated/daw_range_reference.h index cf7393620..c18998171 100644 --- a/include/daw/deprecated/daw_range_reference.h +++ b/include/daw/deprecated/daw_range_reference.h @@ -450,8 +450,7 @@ namespace daw { template constexpr bool is_range_reference_v = is_range_reference::value; - template, std::nullptr_t> = nullptr> OStream &operator<<( OStream &os, ReferenceRange const &rng ) { diff --git a/include/daw/deprecated/daw_safe_string.h b/include/daw/deprecated/daw_safe_string.h index af60f71db..e4e22a7b2 100644 --- a/include/daw/deprecated/daw_safe_string.h +++ b/include/daw/deprecated/daw_safe_string.h @@ -14,8 +14,7 @@ #include namespace daw { - template, typename Alloc = std::allocator> struct basic_safe_string { @@ -75,9 +74,7 @@ namespace daw { template using safe_u32string = basic_safe_string; - template auto make_safe_string( std::basic_string unsafe_string, SanitizeFunction &&sanitize_function ) { @@ -85,8 +82,7 @@ namespace daw { std::move( unsafe_string ), DAW_FWD( sanitize_function ) }; } - template, typename Alloc = std::allocator> auto make_safe_string( charT const *const unsafe_cstring, diff --git a/include/daw/deprecated/daw_string.h b/include/daw/deprecated/daw_string.h index e7ca7420d..14fdc443f 100644 --- a/include/daw/deprecated/daw_string.h +++ b/include/daw/deprecated/daw_string.h @@ -181,9 +181,8 @@ namespace daw::string { } template - auto string_join( Arg1 const &arg1, - Arg2 const &arg2 ) -> decltype( to_string( arg1 ) + - to_string( arg2 ) ) { + auto string_join( Arg1 const &arg1, Arg2 const &arg2 ) + -> decltype( to_string( arg1 ) + to_string( arg2 ) ) { return to_string( arg1 ) + to_string( arg2 ); } @@ -286,8 +285,7 @@ namespace daw::string { } } // namespace string_details - template, + template, typename Allocator = std::allocator> auto trim_right_copy( std::basic_string const &str, @@ -299,8 +297,7 @@ namespace daw::string { return str.substr( 0, str.find_last_not_of( delimiters ) + 1 ); } - template, + template, typename Allocator = std::allocator> void trim_right( std::basic_string &str, @@ -312,8 +309,7 @@ namespace daw::string { str = str.substr( 0, str.find_last_not_of( delimiters ) + 1 ); } - template, + template, typename Allocator = std::allocator> auto trim_left_copy( std::basic_string const &str, @@ -325,8 +321,7 @@ namespace daw::string { return str.substr( str.find_first_not_of( delimiters ) ); } - template, + template, typename Allocator = std::allocator> void trim_left( std::basic_string &str, @@ -343,8 +338,7 @@ namespace daw::string { return StringType::npos != values.find( val ); } - template, + template, typename Allocator = std::allocator> void trim( std::basic_string &str, std::basic_string const &delimiters = @@ -359,8 +353,7 @@ namespace daw::string { str = str.substr( start, len ); } - template, + template, typename Allocator = std::allocator> auto trim_copy( std::basic_string str, @@ -370,8 +363,7 @@ namespace daw::string { return str; } - template, + template, typename Allocator = std::allocator> bool contains( std::basic_string const &str, std::basic_string const &match ) { @@ -379,12 +371,10 @@ namespace daw::string { std::basic_string::npos; } - template, + template, typename Alloc = std::allocator> void search_replace( std::basic_string &in_str, - CharT const *search_for, - CharT const *replace_with ) { + CharT const *search_for, CharT const *replace_with ) { struct { inline auto operator( )( wchar_t const *ptr ) const noexcept { return wcslen( ptr ); @@ -405,8 +395,7 @@ namespace daw::string { } } - template, + template, typename Alloc = std::allocator> auto search_replace_copy( std::basic_string in_str, CharT const *search_for, @@ -420,8 +409,7 @@ namespace daw::string { using can_construct_string = decltype( std::string( std::declval( )... ) ); - template, + template, typename Allocator = std::allocator> struct BasicString { using values_type = std::basic_string; @@ -482,8 +470,7 @@ namespace daw::string { } }; // BasicString - template, std::nullptr_t> = nullptr> OStream &operator<<( OStream &os, BasicString const &str ) { diff --git a/include/daw/deprecated/daw_string_fmt.h b/include/daw/deprecated/daw_string_fmt.h index afa573d09..bfc0d1506 100644 --- a/include/daw/deprecated/daw_string_fmt.h +++ b/include/daw/deprecated/daw_string_fmt.h @@ -50,28 +50,22 @@ namespace daw { return value.to_string( ); } - template< - typename T, - std::enable_if_t, std::nullptr_t> = nullptr> + template, + std::nullptr_t> = nullptr> inline std::string to_string( T const &value ) { return static_cast( value ); } - template= Sz ), std::nullptr_t> = nullptr> inline std::string get_arg_impl( uint8_t const, Args &&... ) { daw::exception::daw_throw( ); } - template = nullptr> - std::string - get_arg_impl( uint8_t const idx, Arg &&arg, Args &&...args ) { + std::string get_arg_impl( uint8_t const idx, Arg &&arg, + Args &&...args ) { if( Cnt == idx ) { using daw::string_fmt::v1::string_fmt_details::to_string; using std::to_string; @@ -215,18 +209,17 @@ namespace daw { struct private_ctor {}; - DAW_MAKE_REQ_TRAIT( - has_reserve_v, - std::declval( ).reserve( std::declval( ) ) ); + DAW_MAKE_REQ_TRAIT( has_reserve_v, std::declval( ).reserve( + std::declval( ) ) ); } // namespace string_fmt_details template class fmt_t { daw::bounded_vector_t, N / 2> m_tokens; - constexpr static daw:: - bounded_vector_t, N / 2> - parse_tokens( daw::basic_string_view msg ) { + constexpr static daw::bounded_vector_t< + string_fmt_details::parse_token, N / 2> + parse_tokens( daw::basic_string_view msg ) { daw::bounded_vector_t, N / 2> result{ }; size_t sz = 0; @@ -300,10 +293,9 @@ namespace daw { return formatter( DAW_FWD( args )... ); } - template, - size_t N = string_fmt_details::cxstrlen( fmt_string ), - typename... Args> + template< + char const *fmt_string, typename Result = std::basic_string, + size_t N = string_fmt_details::cxstrlen( fmt_string ), typename... Args> constexpr Result fmt( Args &&...args ) { constexpr auto const formatter = fmt_t( string_fmt_details::private_ctor{ }, fmt_string ); diff --git a/include/daw/deprecated/daw_string_view1.h b/include/daw/deprecated/daw_string_view1.h index 86a757a77..f6db85b39 100644 --- a/include/daw/deprecated/daw_string_view1.h +++ b/include/daw/deprecated/daw_string_view1.h @@ -597,24 +597,24 @@ namespace daw { [[nodiscard]] static constexpr int compare( basic_string_view lhs, basic_string_view rhs ) { - auto const str_compare = []( CharT const *p0, CharT const *p1, - std::size_t len ) { - auto const last = p0 + len; - while( p0 != last ) { - if( *p0 != *p1 ) { - if( *p0 < *p1 ) { - return -1; - } - return 1; - } - ++p0; - ++p1; - } - return 0; - }; - - auto cmp = str_compare( lhs.data( ), rhs.data( ), - (std::min)( lhs.size( ), rhs.size( ) ) ); + auto const str_compare = + []( CharT const *p0, CharT const *p1, std::size_t len ) { + auto const last = p0 + len; + while( p0 != last ) { + if( *p0 != *p1 ) { + if( *p0 < *p1 ) { + return -1; + } + return 1; + } + ++p0; + ++p1; + } + return 0; + }; + + auto cmp = str_compare( + lhs.data( ), rhs.data( ), (std::min)( lhs.size( ), rhs.size( ) ) ); if( cmp == 0 ) { if( lhs.size( ) < rhs.size( ) ) { return -1; @@ -760,8 +760,8 @@ namespace daw { if( pos >= size( ) or v.empty( ) ) { return npos; } - auto const iter = details::find_first_of( begin( ) + pos, end( ), - v.begin( ), v.end( ), bp_eq ); + auto const iter = details::find_first_of( + begin( ) + pos, end( ), v.begin( ), v.end( ), bp_eq ); if( end( ) == iter ) { return npos; @@ -875,8 +875,8 @@ namespace daw { to_string( ) const { std::basic_string result; result.reserve( size( ) ); - daw::algorithm::copy_n( begin( ), std::back_inserter( result ), - size( ) ); + daw::algorithm::copy_n( + begin( ), std::back_inserter( result ), size( ) ); return result; } #endif @@ -904,8 +904,10 @@ namespace daw { pos = size( ) - ( pos + 1U ); } auto iter = std::find_first_of( - std::next( rbegin( ), static_cast( pos ) ), rend( ), - s.rbegin( ), s.rend( ) ); + std::next( rbegin( ), static_cast( pos ) ), + rend( ), + s.rbegin( ), + s.rend( ) ); return iter == rend( ) ? npos : reverse_distance( rbegin( ), iter ); } @@ -981,8 +983,11 @@ namespace daw { } const_iterator iter = details::find_first_not_of( - begin( ) + pos, end( ), v.begin( ), - std::next( v.begin( ), static_cast( v.size( ) ) ), bp_eq ); + begin( ) + pos, + end( ), + v.begin( ), + std::next( v.begin( ), static_cast( v.size( ) ) ), + bp_eq ); if( end( ) == iter ) { return npos; } @@ -1443,8 +1448,8 @@ namespace daw { operator+( std::basic_string lhs, daw::sv1::basic_string_view rhs ) { lhs.reserve( lhs.size( ) + rhs.size( ) ); - daw::algorithm::copy( rhs.begin( ), rhs.end( ), - std::back_inserter( lhs ) ); + daw::algorithm::copy( + rhs.begin( ), rhs.end( ), std::back_inserter( lhs ) ); return lhs; } @@ -1481,8 +1486,8 @@ namespace daw { std::basic_string const &rhs ) { std::basic_string result; result.reserve( lhs.size( ) + rhs.size( ) ); - daw::algorithm::copy( lhs.begin( ), lhs.end( ), - std::back_inserter( result ) ); + daw::algorithm::copy( + lhs.begin( ), lhs.end( ), std::back_inserter( result ) ); result += rhs; return result; } diff --git a/include/daw/deprecated/daw_vector.h b/include/daw/deprecated/daw_vector.h index 4dfa08a35..bd8941bdb 100644 --- a/include/daw/deprecated/daw_vector.h +++ b/include/daw/deprecated/daw_vector.h @@ -101,9 +101,12 @@ namespace daw { private: [[nodiscard]] static inline pointer allocate_raw( size_type count ) { - T *result = - reinterpret_cast( ::mmap( nullptr, count, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0 ) ); + T *result = reinterpret_cast( ::mmap( nullptr, + count, + PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, + -1, + 0 ) ); if( DAW_UNLIKELY( not result ) ) { DAW_THROW_OR_TERMINATE_NA( std::bad_alloc ); } @@ -697,8 +700,8 @@ namespace daw { return false; } - return std::equal( m_first, m_size, rhs.m_first, - std::not_equal_to{ } ); + return std::equal( + m_first, m_size, rhs.m_first, std::not_equal_to{ } ); } }; diff --git a/include/daw/deprecated/not_null.h b/include/daw/deprecated/not_null.h index 2f1ca7def..12516d8ea 100644 --- a/include/daw/deprecated/not_null.h +++ b/include/daw/deprecated/not_null.h @@ -38,9 +38,8 @@ namespace daw { static_assert( std::is_assignable_v, "T cannot be assigned nullptr." ); - template< - typename U, - std::enable_if_t, std::nullptr_t> = nullptr> + template, + std::nullptr_t> = nullptr> constexpr not_null( U ptr ) : m_ptr( static_cast( ptr ) ) { diff --git a/include/daw/impl/daw_container_help_impl.h b/include/daw/impl/daw_container_help_impl.h index 3434a4b9e..5752dcfdf 100644 --- a/include/daw/impl/daw_container_help_impl.h +++ b/include/daw/impl/daw_container_help_impl.h @@ -67,10 +67,8 @@ namespace daw { public: explicit container_data( ) = default; - explicit constexpr container_data( pointer buff, - Allocator alloc, - size_type sz, - size_type cap ) + explicit constexpr container_data( pointer buff, Allocator alloc, + size_type sz, size_type cap ) : m_data( buff, deleter_type( std::move( alloc ), cap ) ) , m_size( sz ) {} diff --git a/include/daw/impl/daw_container_help_ins_ext.h b/include/daw/impl/daw_container_help_ins_ext.h index 89f3b565c..9a0b0fd8a 100644 --- a/include/daw/impl/daw_container_help_ins_ext.h +++ b/include/daw/impl/daw_container_help_ins_ext.h @@ -26,10 +26,8 @@ namespace daw { } template - constexpr void insert_into_container( Container &vec, - Pointer *buff, - Allocator alloc, - std::size_t capacity, + constexpr void insert_into_container( Container &vec, Pointer *buff, + Allocator alloc, std::size_t capacity, std::size_t size ) { insert_into_container_t{ }( vec, buff, std::move( alloc ), capacity, size ); diff --git a/include/daw/impl/daw_container_help_string.h b/include/daw/impl/daw_container_help_string.h index e332a1ddc..865e935df 100644 --- a/include/daw/impl/daw_container_help_string.h +++ b/include/daw/impl/daw_container_help_string.h @@ -195,8 +195,8 @@ namespace daw::string_extract_impl { S_copy_chars( _p, _k1.base( ), _k2.base( ) ); } - static void - S_copy_chars( CharT *_p, const_iterator _k1, const_iterator _k2 ) noexcept { + static void S_copy_chars( CharT *_p, const_iterator _k1, + const_iterator _k2 ) noexcept { S_copy_chars( _p, _k1.base( ), _k2.base( ) ); } @@ -204,8 +204,8 @@ namespace daw::string_extract_impl { S_copy( _p, _k1, _k2 - _k1 ); } - static void - S_copy_chars( CharT *_p, const CharT *_k1, const CharT *_k2 ) noexcept { + static void S_copy_chars( CharT *_p, const CharT *_k1, + const CharT *_k2 ) noexcept { S_copy( _p, _k1, _k2 - _k1 ); } @@ -223,9 +223,7 @@ namespace daw::string_extract_impl { void m_assign( const basic_string & ); - void m_mutate( size_type _pos, - size_type _len1, - const CharT *_s, + void m_mutate( size_type _pos, size_type _len1, const CharT *_s, size_type _len2 ); void m_erase( size_type _pos, size_type _n ); @@ -237,8 +235,7 @@ namespace daw::string_extract_impl { } template - void m_construct( CharT const *beg, - CharT const *end, + void m_construct( CharT const *beg, CharT const *end, std::random_access_iterator_tag ) { auto const dnew = static_cast( std::distance( beg, end ) ); @@ -275,9 +272,8 @@ namespace daw::string_extract_impl { * @param _str Source string. */ basic_string( const basic_string &_str ) - : m_dataplus( - m_local_data( ), - Alloc_traits::_S_select_on_copy( _str.m_get_allocator( ) ) ) { + : m_dataplus( m_local_data( ), Alloc_traits::_S_select_on_copy( + _str.m_get_allocator( ) ) ) { m_construct( _str.m_data( ), _str.m_data( ) + _str.length( ), std::forward_iterator_tag( ) ); @@ -291,8 +287,7 @@ namespace daw::string_extract_impl { * @param _pos Index of first character to copy from. * @param _a Allocator to use. */ - basic_string( const basic_string &_str, - size_type _pos, + basic_string( const basic_string &_str, size_type _pos, const Alloc &_a = Alloc( ) ) : m_dataplus( m_local_data( ), _a ) { const CharT *_start = @@ -324,9 +319,7 @@ namespace daw::string_extract_impl { * @param _n Number of characters to copy. * @param _a Allocator to use. */ - basic_string( const basic_string &_str, - size_type _pos, - size_type _n, + basic_string( const basic_string &_str, size_type _pos, size_type _n, const Alloc &_a ) : m_dataplus( m_local_data( ), _a ) { const CharT *_start = @@ -746,8 +739,7 @@ namespace daw::string_extract_impl { #if __cplusplus > 201703L [[deprecated( "use shrink_to_fit() instead" )]] #endif - void - reserve( ); + void reserve( ); /** * Erases the string, making it empty. @@ -892,27 +884,20 @@ namespace daw::string_extract_impl { private: template - basic_string &m_replace_dispatch( const_iterator _i1, - const_iterator _i2, - Integer _n, - Integer _val, - __true_type ) { + basic_string &m_replace_dispatch( const_iterator _i1, const_iterator _i2, + Integer _n, Integer _val, __true_type ) { return m_replace_aux( _i1 - begin( ), _i2 - _i1, _n, _val ); } template - basic_string &m_replace_dispatch( const_iterator _i1, - const_iterator _i2, - InputIterator _k1, - InputIterator _k2, + basic_string &m_replace_dispatch( const_iterator _i1, const_iterator _i2, + InputIterator _k1, InputIterator _k2, __false_type ); - basic_string & - m_replace_aux( size_type _pos1, size_type _n1, size_type _n2, CharT _c ); + basic_string &m_replace_aux( size_type _pos1, size_type _n1, size_type _n2, + CharT _c ); - basic_string &m_replace( size_type _pos, - size_type _len1, - const CharT *_s, + basic_string &m_replace( size_type _pos, size_type _len1, const CharT *_s, const size_type _len2 ); basic_string &m_append( const CharT *_s, size_type _n ); diff --git a/include/daw/impl/daw_container_help_vector.h b/include/daw/impl/daw_container_help_vector.h index 43a1be64f..6663f7f60 100644 --- a/include/daw/impl/daw_container_help_vector.h +++ b/include/daw/impl/daw_container_help_vector.h @@ -94,37 +94,38 @@ namespace daw { } } template -struct StdVecStart : daw::pa::member_variable_wrapper< - std::vector, - typename std::vector::pointer> {}; +struct StdVecStart + : daw::pa::member_variable_wrapper< + std::vector, typename std::vector::pointer> { +}; template struct daw::pa::make_proxy, - &std::vector::_M_start>; + &std::vector::_M_start>; template -struct StdVecFinish : daw::pa::member_variable_wrapper< - std::vector, - typename std::vector::pointer> {}; +struct StdVecFinish + : daw::pa::member_variable_wrapper< + std::vector, typename std::vector::pointer> { +}; template struct daw::pa::make_proxy, - &std::vector::_M_finish>; + &std::vector::_M_finish>; template -struct StdVecEndOfStorage : daw::pa::member_variable_wrapper< - std::vector, - typename std::vector::pointer> {}; +struct StdVecEndOfStorage + : daw::pa::member_variable_wrapper< + std::vector, typename std::vector::pointer> { +}; template -struct daw::pa::make_proxy< - StdVecEndOfStorage, - &std::vector::_M_end_of_storage>; +struct daw::pa::make_proxy, + &std::vector::_M_end_of_storage>; template struct StdVecImpl - : daw::pa::member_variable_wrapper, - Allocator> {}; + : daw::pa::member_variable_wrapper, Allocator> {}; template struct daw::pa::make_proxy, - &std::vector::_M_impl>; + &std::vector::_M_impl>; namespace daw { namespace container_help_impl { @@ -306,10 +307,8 @@ namespace daw { explicit insert_into_container_t( ) = default; - constexpr void operator( )( std::vector &vec, - pointer buff, - alloc_type alloc, - std::size_t capacity, + constexpr void operator( )( std::vector &vec, pointer buff, + alloc_type alloc, std::size_t capacity, std::size_t size ) const { using vec_t = std::vector; using layout_t = container_help_impl::std_vector_layout; diff --git a/include/daw/impl/daw_int_to_iterator.h b/include/daw/impl/daw_int_to_iterator.h index d31864744..ee468979f 100644 --- a/include/daw/impl/daw_int_to_iterator.h +++ b/include/daw/impl/daw_int_to_iterator.h @@ -198,7 +198,8 @@ namespace daw { value = -value; } for( auto p10 = pow10( whole_log10( value ) ); - p10 >= 1; p10 /= static_cast( 10 ) ) { + p10 >= 1; + p10 /= static_cast( 10 ) ) { auto const tmp = value / p10; diff --git a/include/daw/impl/daw_is_string_view_like.h b/include/daw/impl/daw_is_string_view_like.h index ace38cd03..4f52b764f 100644 --- a/include/daw/impl/daw_is_string_view_like.h +++ b/include/daw/impl/daw_is_string_view_like.h @@ -16,19 +16,18 @@ namespace daw::traits_is_sv { template inline constexpr bool is_string_view_like_v< - S, - std::void_t< - decltype( ( (void)std::declval( ).begin( ) ), /* has begin( - ) member */ - ( (void)std::declval( ).end( ) ), /* has end( ) - member */ - ( (void)std::declval( )[0] ), /* has integer - subscript */ - ( (void)std::declval( ).empty( ) ), /* has empty( - ) member */ - ( (void)std::declval( ).data( ) ), /* has data( ) - member */ - ( (void)std::declval( ).size( ) ) /* has size( ) - member */ - )>> = true; + S, std::void_t< + decltype( ( (void)std::declval( ).begin( ) ), /* has begin( + ) member */ + ( (void)std::declval( ).end( ) ), /* has end( ) + member */ + ( (void)std::declval( )[0] ), /* has integer + subscript */ + ( (void)std::declval( ).empty( ) ), /* has empty( + ) member */ + ( (void)std::declval( ).data( ) ), /* has data( ) + member */ + ( (void)std::declval( ).size( ) ) /* has size( ) + member */ + )>> = true; } // namespace daw::traits_is_sv diff --git a/include/daw/impl/daw_make_trait.h b/include/daw/impl/daw_make_trait.h index 2a51aa2af..eea261448 100644 --- a/include/daw/impl/daw_make_trait.h +++ b/include/daw/impl/daw_make_trait.h @@ -11,43 +11,33 @@ #include "daw/daw_cpp_feature_check.h" #if not defined( DAW_CPP20_REQUIRES ) -#if defined( DAW_HAS_CPP20_CONCEPTS ) +#if defined( DAW_HAS_CPP20_CONCEPTS ) #define DAW_CPP20_REQUIRES( ... ) requires( __VA_ARGS__ ) #else #define DAW_CPP20_REQUIRES( ... ) #endif #endif -#if defined( DAW_HAS_CPP20_CONCEPTS ) +#if defined( DAW_HAS_CPP20_CONCEPTS ) #define DAW_MAKE_REQ_TRAIT( Name, /*ReqExpression*/... ) \ template \ - inline constexpr bool Name = requires { \ - __VA_ARGS__; \ - } + inline constexpr bool Name = requires { __VA_ARGS__; } #define DAW_MAKE_REQ_TRAIT2( Name, /*ReqExpression*/... ) \ template \ - inline constexpr bool Name = requires { \ - __VA_ARGS__; \ - } + inline constexpr bool Name = requires { __VA_ARGS__; } #define DAW_MAKE_REQ_TRAIT3( Name, /*ReqExpression*/... ) \ template \ - inline constexpr bool Name = requires { \ - __VA_ARGS__; \ - } + inline constexpr bool Name = requires { __VA_ARGS__; } #define DAW_MAKE_REQ_TRAIT_TYPE( Name, /*ReqExpression*/... ) \ template \ - inline constexpr bool Name = requires { \ - typename __VA_ARGS__; \ - } + inline constexpr bool Name = requires { typename __VA_ARGS__; } #define DAW_MAKE_REQ_TRAIT2D( Name, /*ReqExpression*/... ) \ template \ - inline constexpr bool Name = requires { \ - __VA_ARGS__; \ - } + inline constexpr bool Name = requires { __VA_ARGS__; } #else #define DAW_MAKE_REQ_TRAIT( Name, /*ReqExpression*/... ) \ template \ diff --git a/include/daw/impl/daw_string_impl.h b/include/daw/impl/daw_string_impl.h index 0446fae0a..abcf88f55 100644 --- a/include/daw/impl/daw_string_impl.h +++ b/include/daw/impl/daw_string_impl.h @@ -23,10 +23,9 @@ namespace daw { namespace details { template - [[nodiscard]] constexpr ForwardIt1 search( ForwardIt1 first, - ForwardIt1 last, - ForwardIt2 s_first, - ForwardIt2 s_last ) { + [[nodiscard]] constexpr ForwardIt1 + search( ForwardIt1 first, ForwardIt1 last, ForwardIt2 s_first, + ForwardIt2 s_last ) { for( ;; ++first ) { ForwardIt1 it = first; for( ForwardIt2 s_it = s_first;; ++it, ++s_it ) { @@ -44,11 +43,9 @@ namespace daw { } template - [[nodiscard]] constexpr ForwardIt1 search( ForwardIt1 first, - ForwardIt1 last, - ForwardIt2 s_first, - ForwardIt2 s_last, - BinaryPredicate p ) { + [[nodiscard]] constexpr ForwardIt1 + search( ForwardIt1 first, ForwardIt1 last, ForwardIt2 s_first, + ForwardIt2 s_last, BinaryPredicate p ) { for( ;; ++first ) { ForwardIt1 it = first; for( ForwardIt2 s_it = s_first;; ++it, ++s_it ) { @@ -83,8 +80,8 @@ namespace daw { } template - [[nodiscard]] constexpr SizeT - sstrlen( CharT const *const str, SizeT count, SizeT npos ) noexcept { + [[nodiscard]] constexpr SizeT sstrlen( CharT const *const str, SizeT count, + SizeT npos ) noexcept { #ifndef __GNUC__ // Bug in C++ says this isn't a constexpr if( nullptr == str ) { @@ -98,11 +95,9 @@ namespace daw { } template - [[nodiscard]] constexpr InputIt find_first_of( InputIt first, - InputIt last, - ForwardIt s_first, - ForwardIt s_last, - BinaryPredicate p ) { + [[nodiscard]] constexpr InputIt + find_first_of( InputIt first, InputIt last, ForwardIt s_first, + ForwardIt s_last, BinaryPredicate p ) { static_assert( traits::is_binary_prdicate_v< BinaryPredicate, @@ -122,11 +117,9 @@ namespace daw { } template - [[nodiscard]] constexpr InputIt find_first_not_of( InputIt first, - InputIt last, - ForwardIt s_first, - ForwardIt s_last, - BinaryPredicate p ) { + [[nodiscard]] constexpr InputIt + find_first_not_of( InputIt first, InputIt last, ForwardIt s_first, + ForwardIt s_last, BinaryPredicate p ) { static_assert( traits::is_binary_prdicate_v< BinaryPredicate, @@ -152,8 +145,8 @@ namespace daw { } template - [[nodiscard]] constexpr int - compare( CharT const *l_ptr, CharT const *r_ptr, std::size_t sz ) { + [[nodiscard]] constexpr int compare( CharT const *l_ptr, CharT const *r_ptr, + std::size_t sz ) { return std::char_traits::compare( l_ptr, r_ptr, sz ); } @@ -213,9 +206,7 @@ namespace daw { } } - template, std::nullptr_t> = nullptr> @@ -240,9 +231,7 @@ namespace daw { } } - template, std::nullptr_t> = nullptr> void diff --git a/include/daw/impl/daw_traits_impl.h b/include/daw/impl/daw_traits_impl.h index 9d37502d0..b69f70711 100644 --- a/include/daw/impl/daw_traits_impl.h +++ b/include/daw/impl/daw_traits_impl.h @@ -13,10 +13,10 @@ #include "daw/daw_empty.h" #include "daw/daw_move.h" #include "daw/daw_remove_cvref.h" +#include "daw/impl/daw_make_trait.h" #include "daw/traits/daw_traits_identity.h" #include "daw/traits/daw_traits_nth_element.h" #include "daw/traits/daw_traits_pack_list.h" -#include "daw/impl/daw_make_trait.h" #include #include @@ -93,9 +93,8 @@ namespace daw { DAW_MAKE_REQ_TRAIT( has_integer_subscript_v, std::declval( )[0U] ); - DAW_MAKE_REQ_TRAIT( - has_size_memberfn_v, - std::declval( ) = std::declval( ).size( ) ); + DAW_MAKE_REQ_TRAIT( has_size_memberfn_v, std::declval( ) = + std::declval( ).size( ) ); DAW_MAKE_REQ_TRAIT( has_empty_memberfn_v, @@ -136,8 +135,7 @@ namespace daw { template inline constexpr bool is_assignable_iterator_v< - Iterator, - T, + Iterator, T, std::void_t( ) = std::declval( ) )>> = true; @@ -218,9 +216,8 @@ namespace daw { template struct void_function< - Function, - std::enable_if_t, - std::nullptr_t>> { + Function, std::enable_if_t, + std::nullptr_t>> { Function function; @@ -253,9 +250,8 @@ namespace daw { template struct void_function< - Function, - std::enable_if_t, - std::nullptr_t>> { + Function, std::enable_if_t, + std::nullptr_t>> { Function function; diff --git a/include/daw/iterator/daw_split_iterator.h b/include/daw/iterator/daw_split_iterator.h index f4917321b..5d3769985 100644 --- a/include/daw/iterator/daw_split_iterator.h +++ b/include/daw/iterator/daw_split_iterator.h @@ -174,8 +174,8 @@ namespace daw { DAW_FWD( splitter ) ) {} constexpr split_it( ) noexcept - : m_data{ { }, { } } - , m_position{ { }, { } } + : m_data{ { }, {} } + , m_position{ { }, {} } , m_splitter{ } {} ~split_it( ) noexcept = default; @@ -407,8 +407,8 @@ namespace daw { DAW_FWD( splitter ) ) {} constexpr split_it( ) noexcept - : m_data{ { }, { } } - , m_position{ { }, { } } + : m_data{ { }, {} } + , m_position{ { }, {} } , m_splitter{ } {} ~split_it( ) noexcept = default; diff --git a/include/daw/pipelines/algorithm.h b/include/daw/pipelines/algorithm.h index 28791c31a..68a82eb9a 100644 --- a/include/daw/pipelines/algorithm.h +++ b/include/daw/pipelines/algorithm.h @@ -31,10 +31,10 @@ namespace daw::pipelines { DAW_NO_UNIQUE_ADDRESS Projection m_projection{ }; template - requires( not Range ) // - [[nodiscard]] DAW_CPP23_STATIC_CALL_OP constexpr auto - operator( )( C &&compare, - P &&projection = P{ } ) DAW_CPP23_STATIC_CALL_OP_CONST { + requires( not Range ) + [[nodiscard]] DAW_CPP23_STATIC_CALL_OP constexpr auto + operator( )( C &&compare, + P &&projection = P{ } ) DAW_CPP23_STATIC_CALL_OP_CONST { return Sort_t{ DAW_FWD( compare ), DAW_FWD( projection ) }; } @@ -66,11 +66,10 @@ namespace daw::pipelines { DAW_NO_UNIQUE_ADDRESS Projection m_projection{ }; template - requires( not Range ) // - [[nodiscard]] DAW_CPP23_STATIC_CALL_OP - constexpr auto operator( )( C &&compare, - P &&projection = Projection{ } ) - DAW_CPP23_STATIC_CALL_OP_CONST { + requires( not Range ) + [[nodiscard]] DAW_CPP23_STATIC_CALL_OP constexpr auto + operator( )( C &&compare, P &&projection = Projection{ } ) + DAW_CPP23_STATIC_CALL_OP_CONST { return Max_t{ DAW_FWD( compare ), DAW_FWD( projection ) }; } @@ -100,11 +99,10 @@ namespace daw::pipelines { DAW_NO_UNIQUE_ADDRESS Projection m_projection{ }; template - requires( not Range ) // - [[nodiscard]] DAW_CPP23_STATIC_CALL_OP - constexpr auto operator( )( C &&compare, - P &&projection = Projection{ } ) - DAW_CPP23_STATIC_CALL_OP_CONST { + requires( not Range ) + [[nodiscard]] DAW_CPP23_STATIC_CALL_OP constexpr auto + operator( )( C &&compare, P &&projection = Projection{ } ) + DAW_CPP23_STATIC_CALL_OP_CONST { return Min_t{ DAW_FWD( compare ), DAW_FWD( projection ) }; } @@ -134,11 +132,10 @@ namespace daw::pipelines { DAW_NO_UNIQUE_ADDRESS Projection m_projection{ }; template - requires( not Range ) // - [[nodiscard]] DAW_CPP23_STATIC_CALL_OP - constexpr auto operator( )( C &&compare, - P &&projection = Projection{ } ) - DAW_CPP23_STATIC_CALL_OP_CONST { + requires( not Range ) + [[nodiscard]] DAW_CPP23_STATIC_CALL_OP constexpr auto + operator( )( C &&compare, P &&projection = Projection{ } ) + DAW_CPP23_STATIC_CALL_OP_CONST { return MinMax_t{ DAW_FWD( compare ), DAW_FWD( projection ) }; } diff --git a/include/daw/pipelines/cache_last_view.h b/include/daw/pipelines/cache_last_view.h index 7bb9560f5..79b89bcd9 100644 --- a/include/daw/pipelines/cache_last_view.h +++ b/include/daw/pipelines/cache_last_view.h @@ -65,16 +65,20 @@ namespace daw::pipelines { return result; } - constexpr cache_last_iterator &operator--( ) requires( - std::is_same_v ) { + constexpr cache_last_iterator &operator--( ) + requires( + std::is_same_v ) + { m_cached.reset( ); --m_iterator; return *this; } - [[nodiscard]] constexpr cache_last_iterator operator--( int ) requires( - std::is_same_v ) { + [[nodiscard]] constexpr cache_last_iterator operator--( int ) + requires( + std::is_same_v ) + { auto result = *this; operator--( ); diff --git a/include/daw/pipelines/chunk.h b/include/daw/pipelines/chunk.h index 2143900d5..b1cd3cace 100644 --- a/include/daw/pipelines/chunk.h +++ b/include/daw/pipelines/chunk.h @@ -36,16 +36,15 @@ namespace daw::pipelines::pimpl { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline chunk_iterator_end & - operator++( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE chunk_iterator_end &operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline chunk_iterator_end + [[noreturn]] DAW_ATTRIB_NOINLINE chunk_iterator_end operator++( int ) const { std::terminate( ); } @@ -147,7 +146,8 @@ namespace daw::pipelines::pimpl { [[nodiscard]] constexpr bool operator==( chunk_iterator_end const & ) const - requires( not std::same_as ) { + requires( not std::same_as ) + { return not good( ); } }; diff --git a/include/daw/pipelines/concat.h b/include/daw/pipelines/concat.h index e18291f9f..852020383 100644 --- a/include/daw/pipelines/concat.h +++ b/include/daw/pipelines/concat.h @@ -55,16 +55,16 @@ namespace daw::pipelines { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline concat_iterator_end & + [[noreturn]] DAW_ATTRIB_NOINLINE concat_iterator_end & operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline concat_iterator_end + [[noreturn]] DAW_ATTRIB_NOINLINE concat_iterator_end operator++( int ) const { std::terminate( ); } @@ -86,8 +86,7 @@ namespace daw::pipelines { range_reference_t>...>; using const_reference = std::common_reference_t< range_const_reference_t>...>; - using difference_type = - widest_type_t...>; + using difference_type = widest_type_t...>; using i_am_a_daw_concat_iterator_class = void; private: @@ -201,8 +200,7 @@ namespace daw::pipelines { range_reference_t>...>; using const_reference = std::common_reference_t< range_const_reference_t>...>; - using difference_type = - widest_type_t...>; + using difference_type = widest_type_t...>; using position_t = pimpl::variant_range_storage_t< view_t, iterator_end_t>...>; @@ -266,8 +264,8 @@ namespace daw::pipelines { } template - requires( daw::is_tuple_like_v ) // - consteval bool is_tuple_of_fwd_ranges( ) { + requires( daw::is_tuple_like_v ) + consteval bool is_tuple_of_fwd_ranges( ) { return []( std::index_sequence ) { return ( ForwardRange> and ... ); }( std::make_index_sequence>{ } ); diff --git a/include/daw/pipelines/counted_source.h b/include/daw/pipelines/counted_source.h index 7c2e71077..7ddd5c7ab 100644 --- a/include/daw/pipelines/counted_source.h +++ b/include/daw/pipelines/counted_source.h @@ -22,8 +22,8 @@ namespace daw::pipelines::pimpl { template concept counted_source = RandomIterator and requires( First f, Last l ) { - { l - f }->std::convertible_to; - }; + { l - f } -> std::convertible_to; + }; /// The number of elements from first to last. A distance that does not fit /// in std::ptrdiff_t, e.g. an iota_view that runs to the largest diff --git a/include/daw/pipelines/daw_concept_checker.h b/include/daw/pipelines/daw_concept_checker.h index d2f89cfac..a6c807b2e 100644 --- a/include/daw/pipelines/daw_concept_checker.h +++ b/include/daw/pipelines/daw_concept_checker.h @@ -32,7 +32,9 @@ namespace daw { static_assert( requires { typename std::iter_difference_t; } ); static_assert( daw::is_integral_v> ); static_assert( daw::is_signed_v> ); - static_assert( requires( I i ) { { ++i }->std::same_as; } ); + static_assert( requires( I i ) { + { ++i } -> std::same_as; + } ); static_assert( requires( I i ) { i++; } ); return true; } @@ -40,7 +42,9 @@ namespace daw { template DAW_CONSTEVAL bool check_input_or_output_iterator( ) { static_assert( requires( I i ) { *i; } ); - static_assert( requires( I i ) { { *i }->not_same_as; } ); + static_assert( requires( I i ) { + { *i } -> not_same_as; + } ); check_weakly_incrementable( ); return true; } @@ -51,11 +55,12 @@ namespace daw { static_assert( requires { typename std::iter_reference_t; } ); static_assert( requires { typename std::iter_rvalue_reference_t; } ); static_assert( requires( I const in ) { - { *in }->std::same_as>; + { *in } -> std::same_as>; } ); static_assert( requires( I const in ) { - { std::ranges::iter_move( in ) } - ->std::same_as>; + { + std::ranges::iter_move( in ) + } -> std::same_as>; } ); static_assert( std::common_reference_with &&, std::iter_value_t &> ); @@ -88,19 +93,19 @@ namespace daw { DAW_CONSTEVAL bool check_weakly_equality_comparible_with( ) { static_assert( requires( std::remove_reference_t const &t, std::remove_reference_t const &u ) { - { t == u }->convertible_to; + { t == u } -> convertible_to; } ); static_assert( requires( std::remove_reference_t const &t, std::remove_reference_t const &u ) { - { t != u }->convertible_to; + { t != u } -> convertible_to; } ); static_assert( requires( std::remove_reference_t const &t, std::remove_reference_t const &u ) { - { u == t }->convertible_to; + { u == t } -> convertible_to; } ); static_assert( requires( std::remove_reference_t const &t, std::remove_reference_t const &u ) { - { u != t }->convertible_to; + { u != t } -> convertible_to; } ); return true; } diff --git a/include/daw/pipelines/elements.h b/include/daw/pipelines/elements.h index 51370cb5e..09436dfdc 100644 --- a/include/daw/pipelines/elements.h +++ b/include/daw/pipelines/elements.h @@ -58,12 +58,16 @@ namespace daw::pipelines::pimpl { } [[nodiscard]] DAW_ATTRIB_INLINE constexpr reference - operator[]( size_type n ) requires( RandomIterator ) { + operator[]( size_type n ) + requires( RandomIterator ) + { return raw_get( std::next( m_iter, as( n ) ) ); } [[nodiscard]] DAW_ATTRIB_INLINE constexpr const_reference - operator[]( size_type n ) const requires( RandomIterator ) { + operator[]( size_type n ) const + requires( RandomIterator ) + { return raw_get( std::next( m_iter, as( n ) ) ); } @@ -98,33 +102,40 @@ namespace daw::pipelines::pimpl { } DAW_ATTRIB_INLINE constexpr element_iterator &operator--( ) - requires( BidirectionalIterator ) { + requires( BidirectionalIterator ) + { --m_iter; return *this; } [[nodiscard]] DAW_ATTRIB_INLINE constexpr element_iterator operator--( int ) - requires( BidirectionalIterator ) { + requires( BidirectionalIterator ) + { element_iterator result = *this; --m_iter; return result; } DAW_ATTRIB_INLINE constexpr element_iterator & - operator+=( difference_type n ) requires( RandomIterator ) { + operator+=( difference_type n ) + requires( RandomIterator ) + { m_iter += n; return *this; } DAW_ATTRIB_INLINE constexpr element_iterator & - operator-=( difference_type n ) requires( RandomIterator ) { + operator-=( difference_type n ) + requires( RandomIterator ) + { m_iter -= n; return *this; } [[nodiscard]] DAW_ATTRIB_INLINE constexpr element_iterator operator+( difference_type n ) const noexcept - requires( RandomIterator ) { + requires( RandomIterator ) + { element_iterator result = *this; m_iter += n; return result; @@ -132,7 +143,8 @@ namespace daw::pipelines::pimpl { [[nodiscard]] DAW_ATTRIB_INLINE constexpr element_iterator operator-( difference_type n ) const noexcept - requires( RandomIterator ) { + requires( RandomIterator ) + { element_iterator result = *this; m_iter -= n; return result; @@ -140,7 +152,8 @@ namespace daw::pipelines::pimpl { [[nodiscard]] DAW_ATTRIB_INLINE constexpr difference_type operator-( element_iterator const &rhs ) - requires( RandomIterator ) { + requires( RandomIterator ) + { return m_iter - rhs.m_iter; } @@ -252,12 +265,16 @@ namespace daw::pipelines::pimpl { } [[nodiscard]] DAW_ATTRIB_INLINE constexpr reference - operator[]( size_type n ) requires( RandomIterator ) { + operator[]( size_type n ) + requires( RandomIterator ) + { return raw_get( std::next( m_iter, as( n ) ) ); } [[nodiscard]] DAW_ATTRIB_INLINE constexpr const_reference - operator[]( size_type n ) const requires( RandomIterator ) { + operator[]( size_type n ) const + requires( RandomIterator ) + { return raw_get( std::next( m_iter, as( n ) ) ); } @@ -292,33 +309,41 @@ namespace daw::pipelines::pimpl { } DAW_ATTRIB_INLINE constexpr elements_iterator &operator--( ) - requires( BidirectionalIterator ) { + requires( BidirectionalIterator ) + { --m_iter; return *this; } [[nodiscard]] DAW_ATTRIB_INLINE constexpr elements_iterator - operator--( int ) requires( BidirectionalIterator ) { + operator--( int ) + requires( BidirectionalIterator ) + { elements_iterator result = *this; --m_iter; return result; } DAW_ATTRIB_INLINE constexpr elements_iterator & - operator+=( difference_type n ) requires( RandomIterator ) { + operator+=( difference_type n ) + requires( RandomIterator ) + { m_iter += n; return *this; } DAW_ATTRIB_INLINE constexpr elements_iterator & - operator-=( difference_type n ) requires( RandomIterator ) { + operator-=( difference_type n ) + requires( RandomIterator ) + { m_iter -= n; return *this; } [[nodiscard]] DAW_ATTRIB_INLINE constexpr elements_iterator operator+( difference_type n ) const noexcept - requires( RandomIterator ) { + requires( RandomIterator ) + { elements_iterator result = *this; m_iter += n; return result; @@ -326,7 +351,8 @@ namespace daw::pipelines::pimpl { [[nodiscard]] DAW_ATTRIB_INLINE constexpr elements_iterator operator-( difference_type n ) const noexcept - requires( RandomIterator ) { + requires( RandomIterator ) + { elements_iterator result = *this; m_iter -= n; return result; @@ -334,7 +360,8 @@ namespace daw::pipelines::pimpl { [[nodiscard]] DAW_ATTRIB_INLINE constexpr difference_type operator-( elements_iterator const &rhs ) - requires( RandomIterator ) { + requires( RandomIterator ) + { return m_iter - rhs.m_iter; } diff --git a/include/daw/pipelines/every.h b/include/daw/pipelines/every.h index bfd07003f..8bc0f70b1 100644 --- a/include/daw/pipelines/every.h +++ b/include/daw/pipelines/every.h @@ -34,16 +34,15 @@ namespace daw::pipelines::pimpl { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline every_iterator_end & - operator++( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE every_iterator_end &operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline every_iterator_end + [[noreturn]] DAW_ATTRIB_NOINLINE every_iterator_end operator++( int ) const { std::terminate( ); } diff --git a/include/daw/pipelines/filter.h b/include/daw/pipelines/filter.h index ec0215876..ec7f25c5b 100644 --- a/include/daw/pipelines/filter.h +++ b/include/daw/pipelines/filter.h @@ -42,16 +42,15 @@ namespace daw::pipelines::pimpl { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline filter_iterator_end & - operator++( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE filter_iterator_end &operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline filter_iterator_end + [[noreturn]] DAW_ATTRIB_NOINLINE filter_iterator_end operator++( int ) const { std::terminate( ); } @@ -203,19 +202,17 @@ namespace daw::pipelines { explicit filter_view( ) = default; template - requires( - std::constructible_from and std::constructible_from and - not Iterator ) // - explicit constexpr filter_view( R0 &&r, F &&fn ) + requires( std::constructible_from and + std::constructible_from and not Iterator ) + explicit constexpr filter_view( R0 &&r, F &&fn ) : base_t( DAW_FWD( r ) ) , m_fn{ DAW_FWD( fn ) } {} template - requires( - std::constructible_from and std::constructible_from and - not Iterator and std::constructible_from and - not Iterator

) // - explicit constexpr filter_view( R0 &&r, F &&fn, P &&projection ) + requires( std::constructible_from and + std::constructible_from and not Iterator and + std::constructible_from and not Iterator

) + explicit constexpr filter_view( R0 &&r, F &&fn, P &&projection ) : base_t( DAW_FWD( r ) ) , m_fn{ DAW_FWD( fn ) } , m_proj( DAW_FWD( projection ) ) {} @@ -239,12 +236,12 @@ namespace daw::pipelines { constexpr bool operator==( filter_view const & ) const = default; }; template - requires( not Iterator ) // - filter_view( R &&, F ) -> filter_view; + requires( not Iterator ) + filter_view( R &&, F ) -> filter_view; template - requires( not Iterator and not Iterator

) // - filter_view( R &&, F, P ) -> filter_view, F, P>; + requires( not Iterator and not Iterator

) + filter_view( R &&, F, P ) -> filter_view, F, P>; namespace pimpl { template diff --git a/include/daw/pipelines/find.h b/include/daw/pipelines/find.h index 1c999f6d3..2a9d4d4d3 100644 --- a/include/daw/pipelines/find.h +++ b/include/daw/pipelines/find.h @@ -30,7 +30,7 @@ namespace daw::pipelines::pimpl { finder( Needle const &needle, Projection const &projection, ForwardIterator auto it_current, ProjectedValues &&...projected_values ) - requires( not InputIterator and not InputIterator ) // + requires( not InputIterator and not InputIterator ) { static_assert( C >= 0 ); @@ -71,8 +71,8 @@ namespace daw::pipelines::pimpl { template - requires( FindWidth > 0 ) // - struct FindIf_t { + requires( FindWidth > 0 ) + struct FindIf_t { DAW_NO_UNIQUE_ADDRESS Needle needle; DAW_NO_UNIQUE_ADDRESS Projection projection; @@ -103,35 +103,35 @@ namespace daw::pipelines { /// FindWidth parameters of type range_value_type template - requires( not Range ) // - [[nodiscard]] constexpr auto FindIf( - Needle &&needle, Projection &&projection = Projection{ } ) { + requires( not Range ) + [[nodiscard]] constexpr auto + FindIf( Needle &&needle, Projection &&projection = Projection{ } ) { return pimpl::FindIf_t{ DAW_FWD( needle ), DAW_FWD( projection ) }; } template - requires( not Range ) // - [[nodiscard]] constexpr auto Find( - Needle &&needle, Projection &&projection = Projection{ } ) { + requires( not Range ) + [[nodiscard]] constexpr auto Find( Needle &&needle, + Projection &&projection = Projection{ } ) { return pimpl::FindValue_t{ DAW_FWD( needle ), DAW_FWD( projection ) }; } template - requires( std::invocable> ) // - [[nodiscard]] constexpr auto FindIf( - R &&r, Needle &&needle, Projection &&projection = Projection{ } ) { + requires( std::invocable> ) + [[nodiscard]] constexpr auto + FindIf( R &&r, Needle &&needle, Projection &&projection = Projection{ } ) { return pimpl::FindIf_t{ DAW_FWD( needle ), DAW_FWD( projection ) }( DAW_FWD( r ) ); } template - requires( std::invocable> ) // - [[nodiscard]] constexpr auto Find( - R &&r, Needle &&needle, Projection &&projection = Projection{ } ) { + requires( std::invocable> ) + [[nodiscard]] constexpr auto Find( R &&r, Needle &&needle, + Projection &&projection = Projection{ } ) { return pimpl::FindValue_t{ DAW_FWD( needle ), DAW_FWD( projection ) }( DAW_FWD( r ) ); diff --git a/include/daw/pipelines/flatten.h b/include/daw/pipelines/flatten.h index 30edb05d0..d24321fdf 100644 --- a/include/daw/pipelines/flatten.h +++ b/include/daw/pipelines/flatten.h @@ -39,16 +39,15 @@ namespace daw::pipelines::pimpl { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline flatten_iterator_end & - operator++( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE flatten_iterator_end &operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline flatten_iterator_end + [[noreturn]] DAW_ATTRIB_NOINLINE flatten_iterator_end operator++( int ) const { std::terminate( ); } @@ -176,9 +175,8 @@ namespace daw::pipelines { explicit flatten_view( ) = default; template - requires( not std::same_as, - flatten_view> ) // - explicit constexpr flatten_view( U &&r ) + requires( not std::same_as, flatten_view> ) + explicit constexpr flatten_view( U &&r ) : base_t( DAW_FWD( r ) ) {} [[nodiscard]] constexpr iterator begin( ) { diff --git a/include/daw/pipelines/map.h b/include/daw/pipelines/map.h index 3c8fd9777..9e76b4a2a 100644 --- a/include/daw/pipelines/map.h +++ b/include/daw/pipelines/map.h @@ -59,17 +59,15 @@ namespace daw::pipelines::pimpl { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline map_iterator_end & - operator++( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE map_iterator_end &operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline map_iterator_end - operator++( int ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE map_iterator_end operator++( int ) const { std::terminate( ); } }; @@ -110,19 +108,21 @@ namespace daw::pipelines::pimpl { map_iterator( ) = default; template - requires( std::constructible_from ) // - explicit constexpr map_iterator( MI *parent, First &&first ) + requires( std::constructible_from ) + explicit constexpr map_iterator( MI *parent, First &&first ) : m_parent( parent ) , m_iter( DAW_FWD( first ) ) {} private: [[nodiscard]] constexpr decltype( auto ) raw_get( size_type n ) - requires( RandomIterator ) { + requires( RandomIterator ) + { return *( m_iter + as( n ) ); } [[nodiscard]] constexpr decltype( auto ) raw_get( size_type n ) const - requires( RandomIterator ) { + requires( RandomIterator ) + { return *( m_iter + as( n ) ); } @@ -157,12 +157,14 @@ namespace daw::pipelines::pimpl { } [[nodiscard]] constexpr reference operator[]( size_type n ) - requires( RandomIterator ) { + requires( RandomIterator ) + { return do_func( raw_get( n ) ); } [[nodiscard]] constexpr reference operator[]( size_type n ) const - requires( RandomIterator ) { + requires( RandomIterator ) + { return do_func( raw_get( n ) ); } @@ -194,73 +196,84 @@ namespace daw::pipelines::pimpl { } constexpr map_iterator &operator--( ) - requires( BidirectionalIterator ) { + requires( BidirectionalIterator ) + { --m_iter; return *this; } [[nodiscard]] constexpr map_iterator operator--( int ) - requires( BidirectionalIterator ) { + requires( BidirectionalIterator ) + { map_iterator result = *this; --m_iter; return result; } constexpr map_iterator &operator+=( difference_type n ) - requires( RandomIterator ) { + requires( RandomIterator ) + { m_iter += n; return *this; } constexpr map_iterator &operator-=( difference_type n ) - requires( RandomIterator ) { + requires( RandomIterator ) + { m_iter -= n; return *this; } [[nodiscard]] friend constexpr map_iterator operator+( map_iterator lhs, difference_type n ) noexcept - requires( RandomIterator ) { + requires( RandomIterator ) + { lhs += n; return lhs; } [[nodiscard]] friend constexpr map_iterator operator+( difference_type n, map_iterator rhs ) noexcept - requires( RandomIterator ) { + requires( RandomIterator ) + { rhs += n; return rhs; } [[nodiscard]] friend constexpr map_iterator operator-( map_iterator lhs, difference_type n ) noexcept - requires( RandomIterator ) { + requires( RandomIterator ) + { lhs -= n; return lhs; } [[nodiscard]] friend constexpr map_iterator operator-( difference_type n, map_iterator rhs ) noexcept - requires( RandomIterator ) { + requires( RandomIterator ) + { rhs -= n; return rhs; } [[nodiscard]] constexpr difference_type operator-( map_iterator const &rhs ) const - requires( RandomIterator ) { + requires( RandomIterator ) + { return m_iter - rhs.m_iter; } [[nodiscard]] constexpr difference_type operator-( last_iterator const & ) const - requires( RandomIterator ) { + requires( RandomIterator ) + { return m_iter - m_parent->rend( ); } [[nodiscard]] friend constexpr difference_type operator-( last_iterator const &, map_iterator const &rhs ) - requires( RandomIterator ) { + requires( RandomIterator ) + { return rhs.m_parent->rend( ) - rhs.m_iter; } @@ -322,19 +335,17 @@ namespace daw::pipelines { explicit map_view( ) = default; template - requires( - std::constructible_from and std::constructible_from and - not Iterator ) // - explicit constexpr map_view( R0 &&r, F &&fn ) + requires( std::constructible_from and + std::constructible_from and not Iterator ) + explicit constexpr map_view( R0 &&r, F &&fn ) : base_t( DAW_FWD( r ) ) , m_fn{ DAW_FWD( fn ) } {} template - requires( - std::constructible_from and std::constructible_from and - not Iterator and std::constructible_from and - not Iterator

) // - explicit constexpr map_view( R0 &&r, F &&fn, P &&projection ) + requires( std::constructible_from and + std::constructible_from and not Iterator and + std::constructible_from and not Iterator

) + explicit constexpr map_view( R0 &&r, F &&fn, P &&projection ) : base_t( DAW_FWD( r ) ) , m_fn{ DAW_FWD( fn ) } , m_proj( DAW_FWD( projection ) ) {} @@ -356,12 +367,12 @@ namespace daw::pipelines { } }; template - requires( not Iterator ) // - map_view( R &&, F ) -> map_view; + requires( not Iterator ) + map_view( R &&, F ) -> map_view; template - requires( not Iterator and not Iterator

) // - map_view( R &&, F, P ) -> map_view; + requires( not Iterator and not Iterator

) + map_view( R &&, F, P ) -> map_view; namespace pimpl { template diff --git a/include/daw/pipelines/maybe.h b/include/daw/pipelines/maybe.h index 6bcaf6eeb..0ad6de917 100644 --- a/include/daw/pipelines/maybe.h +++ b/include/daw/pipelines/maybe.h @@ -16,7 +16,8 @@ namespace daw::pipelines { template - struct maybe_view : private pimpl::range_base_t *> { + struct maybe_view + : private pimpl::range_base_t *> { using value_type = std::remove_reference_t; using reference = T &; using pointer = value_type *; diff --git a/include/daw/pipelines/maybe_owning_range.h b/include/daw/pipelines/maybe_owning_range.h index a71ce29ca..993c50b37 100644 --- a/include/daw/pipelines/maybe_owning_range.h +++ b/include/daw/pipelines/maybe_owning_range.h @@ -31,7 +31,8 @@ namespace daw::pipelines { static constexpr bool is_owned = storage_t::is_owned; [[nodiscard]] constexpr auto &get_range( ) & - requires( not std::is_const_v> ) { + requires( not std::is_const_v> ) + { return m_storage.get( ); } diff --git a/include/daw/pipelines/numeric.h b/include/daw/pipelines/numeric.h index 266753de8..f91c52a34 100644 --- a/include/daw/pipelines/numeric.h +++ b/include/daw/pipelines/numeric.h @@ -75,9 +75,9 @@ namespace daw::pipelines { DAW_NO_UNIQUE_ADDRESS Projection m_projection = Projection{ }; template - requires( not Range

) [[nodiscard]] DAW_CPP23_STATIC_CALL_OP - constexpr auto - operator( )( P &&proj ) DAW_CPP23_STATIC_CALL_OP_CONST { + requires( not Range

) + [[nodiscard]] DAW_CPP23_STATIC_CALL_OP constexpr auto + operator( )( P &&proj ) DAW_CPP23_STATIC_CALL_OP_CONST { return SumKahanBabushkaNeumaier_t>{ DAW_FWD( proj ) }; } diff --git a/include/daw/pipelines/pipeline.h b/include/daw/pipelines/pipeline.h index cc4e0df96..2dacf2d55 100644 --- a/include/daw/pipelines/pipeline.h +++ b/include/daw/pipelines/pipeline.h @@ -108,8 +108,8 @@ namespace daw::pipelines { } template - requires( not Range ) // - DAW_ATTRIB_FLATTEN constexpr auto pipeline( Fn &&fn, Fns &&...fns ) { + requires( not Range ) + DAW_ATTRIB_FLATTEN constexpr auto pipeline( Fn &&fn, Fns &&...fns ) { // Store all passed functions as they must outlive the call to pipeline return [tpfns = pimpl::make_tpfns( DAW_FWD( fn ), DAW_FWD( fns )... )]( diff --git a/include/daw/pipelines/range_base.h b/include/daw/pipelines/range_base.h index 10af6ac8a..5f47f8488 100644 --- a/include/daw/pipelines/range_base.h +++ b/include/daw/pipelines/range_base.h @@ -101,7 +101,8 @@ namespace daw::pipelines::pimpl { [[nodiscard]] constexpr bool operator==( stored_range_base_t const &rhs ) const - requires( std::equality_comparable> ) { + requires( std::equality_comparable> ) + { return get( ) == rhs.get( ); } @@ -220,7 +221,8 @@ namespace std { template constexpr auto get( daw::pipelines::pimpl::RangeBase auto &&r ) - requires( I == 0 or I == 1 ) { + requires( I == 0 or I == 1 ) + { if constexpr( I == 0 ) { return DAW_FWD( r ).begin( ); } else { diff --git a/include/daw/pipelines/reverse.h b/include/daw/pipelines/reverse.h index 82d54615a..0fd829a66 100644 --- a/include/daw/pipelines/reverse.h +++ b/include/daw/pipelines/reverse.h @@ -171,7 +171,8 @@ namespace daw::pipelines { using base_t::is_owned; [[nodiscard]] constexpr auto &get_range( ) & - requires( not std::is_const_v> ) { + requires( not std::is_const_v> ) + { return static_cast( this )->get_range( ); } diff --git a/include/daw/pipelines/sized_iterator.h b/include/daw/pipelines/sized_iterator.h index 65defc9c9..7fbfe73a9 100644 --- a/include/daw/pipelines/sized_iterator.h +++ b/include/daw/pipelines/sized_iterator.h @@ -36,16 +36,15 @@ namespace daw::pipelines { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline sized_iterator_end & - operator++( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE sized_iterator_end &operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline sized_iterator_end + [[noreturn]] DAW_ATTRIB_NOINLINE sized_iterator_end operator++( int ) const { std::terminate( ); } @@ -132,7 +131,8 @@ namespace daw::pipelines { [[nodiscard]] constexpr bool operator==( sized_iterator_end const & ) const noexcept - requires( not std::same_as ) { + requires( not std::same_as ) + { return m_count <= 0; } @@ -156,13 +156,15 @@ namespace daw::pipelines { // bidirectional iterator interface constexpr sized_iterator &operator--( ) - requires( BidirectionalIteratorTag ) { + requires( BidirectionalIteratorTag ) + { decrement( ); return *this; } [[nodiscard]] DAW_ATTRIB_INLINE constexpr sized_iterator operator--( int ) - requires( BidirectionalIteratorTag ) { + requires( BidirectionalIteratorTag ) + { auto tmp = *this; decrement( ); return tmp; @@ -171,58 +173,67 @@ namespace daw::pipelines { // random access iterator interface [[nodiscard]] DAW_ATTRIB_INLINE constexpr reference operator[]( difference_type n ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return m_iter[n]; } [[nodiscard]] DAW_ATTRIB_INLINE constexpr reference operator[]( difference_type n ) const - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return m_iter[n]; } constexpr sized_iterator &operator+=( difference_type n ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { advance( n ); return *this; } constexpr sized_iterator &operator-=( difference_type n ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { advance( -n ); return *this; } friend constexpr sized_iterator operator+( sized_iterator lhs, difference_type n ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { lhs += n; return lhs; } friend constexpr sized_iterator operator+( difference_type n, sized_iterator rhs ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { rhs += n; return rhs; } friend constexpr sized_iterator operator-( sized_iterator lhs, difference_type n ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { lhs -= n; return lhs; } friend constexpr sized_iterator operator-( difference_type n, sized_iterator rhs ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { rhs -= n; return rhs; } constexpr difference_type operator-( sized_iterator const &rhs ) const - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return rhs.m_count - m_count; } }; @@ -300,7 +311,8 @@ namespace daw::pipelines { [[nodiscard]] constexpr bool operator==( sized_iterator_end const & ) const noexcept - requires( not std::same_as ) { + requires( not std::same_as ) + { return m_count <= 0 or m_first == m_last; } }; diff --git a/include/daw/pipelines/slide.h b/include/daw/pipelines/slide.h index 15380deb3..7048f26e8 100644 --- a/include/daw/pipelines/slide.h +++ b/include/daw/pipelines/slide.h @@ -40,16 +40,15 @@ namespace daw::pipelines::pimpl { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline slide_iterator_end & - operator++( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE slide_iterator_end &operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline slide_iterator_end + [[noreturn]] DAW_ATTRIB_NOINLINE slide_iterator_end operator++( int ) const { std::terminate( ); } @@ -243,8 +242,7 @@ namespace daw::pipelines::pimpl { explicit slide_view( ) = default; explicit constexpr slide_view( daw::constructible auto &&r ) - requires( - not std::same_as, slide_view> ) + requires( not std::same_as, slide_view> ) : base_t{ DAW_FWD( r ) } {} explicit constexpr slide_view( daw::constructible auto &&r, diff --git a/include/daw/pipelines/split.h b/include/daw/pipelines/split.h index c1b1ef09e..68ddde2a4 100644 --- a/include/daw/pipelines/split.h +++ b/include/daw/pipelines/split.h @@ -59,16 +59,15 @@ namespace daw::pipelines::pimpl { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline split_iterator_end & - operator++( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE split_iterator_end &operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline split_iterator_end + [[noreturn]] DAW_ATTRIB_NOINLINE split_iterator_end operator++( int ) const { std::terminate( ); } diff --git a/include/daw/pipelines/take.h b/include/daw/pipelines/take.h index 91167ae1d..5a50dac24 100644 --- a/include/daw/pipelines/take.h +++ b/include/daw/pipelines/take.h @@ -70,8 +70,8 @@ namespace daw::pipelines { explicit take_view( ) = default; template - requires( std::constructible_from ) // - explicit constexpr take_view( R0 &&r, std::size_t how_many ) + requires( std::constructible_from ) + explicit constexpr take_view( R0 &&r, std::size_t how_many ) : base_t( DAW_FWD( r ) ) , m_how_many( how_many ) {} diff --git a/include/daw/pipelines/to.h b/include/daw/pipelines/to.h index 99728cd0e..d100f7ef6 100644 --- a/include/daw/pipelines/to.h +++ b/include/daw/pipelines/to.h @@ -162,7 +162,7 @@ namespace daw::pipelines { /// std::array, from a Range or a single value template requires( not requires( Container c ) { pimpl::array_test( c ); } ) - [[nodiscard]] constexpr auto To( ) { + [[nodiscard]] constexpr auto To( ) { return pimpl::ToContainer{ }; } @@ -170,7 +170,7 @@ namespace daw::pipelines { /// TODO: add single value method template requires( requires( Array a ) { pimpl::array_test( a ); } ) - [[nodiscard]] constexpr auto To( ) { + [[nodiscard]] constexpr auto To( ) { return pimpl::ToArray{ }; } } // namespace daw::pipelines diff --git a/include/daw/pipelines/unique.h b/include/daw/pipelines/unique.h index 10154aabe..28bdaefd9 100644 --- a/include/daw/pipelines/unique.h +++ b/include/daw/pipelines/unique.h @@ -31,16 +31,15 @@ namespace daw::pipelines { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline unique_iterator_end & - operator++( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE unique_iterator_end &operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline unique_iterator_end + [[noreturn]] DAW_ATTRIB_NOINLINE unique_iterator_end operator++( int ) const { std::terminate( ); } @@ -64,9 +63,9 @@ namespace daw::pipelines { unique_iterator( ) = default; template - requires( std::constructible_from - and std::constructible_from ) // - explicit constexpr unique_iterator( F &&first, L &&last ) + requires( std::constructible_from and + std::constructible_from ) + explicit constexpr unique_iterator( F &&first, L &&last ) : m_first( DAW_FWD( first ) ) , m_last( DAW_FWD( last ) ) {} @@ -143,8 +142,8 @@ namespace daw::pipelines { explicit unique_view( ) = default; template - requires( std::constructible_from ) // - explicit constexpr unique_view( FR &&range ) + requires( std::constructible_from ) + explicit constexpr unique_view( FR &&range ) : base_t( DAW_FWD( range ) ) {} [[nodiscard]] constexpr iterator begin( ) { diff --git a/include/daw/pipelines/view.h b/include/daw/pipelines/view.h index 1515c0ce5..b80f6d424 100644 --- a/include/daw/pipelines/view.h +++ b/include/daw/pipelines/view.h @@ -71,27 +71,32 @@ namespace daw::pipelines { } [[nodiscard]] constexpr std::size_t size( ) const - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return pimpl::ranges_distance( first, last ); } [[nodiscard]] constexpr auto data( ) - requires( std::contiguous_iterator ) { + requires( std::contiguous_iterator ) + { return std::to_address( first ); } [[nodiscard]] constexpr auto data( ) const - requires( std::contiguous_iterator ) { + requires( std::contiguous_iterator ) + { return std::to_address( first ); } [[nodiscard]] constexpr auto data_end( ) - requires( std::contiguous_iterator ) { + requires( std::contiguous_iterator ) + { return std::to_address( last ); } [[nodiscard]] constexpr auto data_end( ) const - requires( std::contiguous_iterator ) { + requires( std::contiguous_iterator ) + { return std::to_address( last ); } @@ -107,26 +112,30 @@ namespace daw::pipelines { } constexpr view_t &operator--( ) - requires( BidirectionalIteratorTag ) { + requires( BidirectionalIteratorTag ) + { --first; return *this; } [[nodiscard]] constexpr view_t operator--( int ) - requires( BidirectionalIteratorTag ) { + requires( BidirectionalIteratorTag ) + { auto result = *this; --first; return result; } [[nodiscard]] constexpr reference operator[]( difference_type idx ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return first[idx]; } [[nodiscard]] constexpr const_reference operator[]( difference_type idx ) const - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return first[idx]; } @@ -155,7 +164,8 @@ namespace daw::pipelines { } [[nodiscard]] constexpr difference_type operator-( view_t const &rhs ) const - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return pimpl::ranges_distance( first, rhs.first ); } diff --git a/include/daw/pipelines/zip.h b/include/daw/pipelines/zip.h index 9af7838b7..108e34a2b 100644 --- a/include/daw/pipelines/zip.h +++ b/include/daw/pipelines/zip.h @@ -36,7 +36,8 @@ namespace daw::pipelines { }; template - requires( sizeof...( Ts ) == 2 ) struct tuple_pair_t { + requires( sizeof...( Ts ) == 2 ) + struct tuple_pair_t { using type = std::pair; }; @@ -60,16 +61,15 @@ namespace daw::pipelines { return true; } - [[noreturn]] DAW_ATTRIB_NOINLINE inline value_type operator*( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE value_type operator*( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline zip_iterator_end & - operator++( ) const { + [[noreturn]] DAW_ATTRIB_NOINLINE zip_iterator_end &operator++( ) const { std::terminate( ); } - [[noreturn]] DAW_ATTRIB_NOINLINE inline zip_iterator_end + [[noreturn]] DAW_ATTRIB_NOINLINE zip_iterator_end operator++( int ) const { std::terminate( ); } @@ -82,8 +82,8 @@ namespace daw::pipelines { struct zip_counted : std::false_type {}; template - requires( sizeof...( SentinelFors ) == sizeof...( Iterators ) ) // - struct zip_counted, Iterators...> + requires( sizeof...( SentinelFors ) == sizeof...( Iterators ) ) + struct zip_counted, Iterators...> : std::bool_constant<( counted_source and ... )> {}; @@ -109,8 +109,8 @@ namespace daw::pipelines { }; template - requires( requires { typename ZR::i_am_a_daw_zip_view_class; } ) // - struct zip_iterator { + requires( requires { typename ZR::i_am_a_daw_zip_view_class; } ) + struct zip_iterator { static_assert( sizeof...( Iterators ) > 0, "Empty zip iterator is unsupported" ); @@ -160,14 +160,16 @@ namespace daw::pipelines { template [[nodiscard]] constexpr reference get_at( difference_type n, std::index_sequence ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return reference{ *std::next( std::get( m_iters ), n )... }; } template [[nodiscard]] constexpr const_reference get_at( difference_type n, std::index_sequence ) const - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return const_reference{ *std::next( std::get( m_iters ), n )... }; } @@ -289,13 +291,15 @@ namespace daw::pipelines { // bidirectional iterator interface constexpr zip_iterator &operator--( ) - requires( BidirectionalIteratorTag ) { + requires( BidirectionalIteratorTag ) + { decrement( zip_indices( ) ); return *this; } [[nodiscard]] constexpr zip_iterator operator--( int ) - requires( BidirectionalIteratorTag ) { + requires( BidirectionalIteratorTag ) + { auto tmp = *this; decrement( zip_indices( ) ); return tmp; @@ -303,57 +307,66 @@ namespace daw::pipelines { // random access iterator interface [[nodiscard]] constexpr reference operator[]( difference_type n ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return get_at( n, zip_indices( ) ); } [[nodiscard]] constexpr reference operator[]( difference_type n ) const - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return get_at( n, zip_indices( ) ); } constexpr zip_iterator &operator+=( difference_type n ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { advance( n, zip_indices( ) ); return *this; } constexpr zip_iterator &operator-=( difference_type n ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { advance( -n, zip_indices( ) ); return *this; } friend constexpr zip_iterator operator+( zip_iterator lhs, difference_type n ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { lhs += n; return lhs; } friend constexpr zip_iterator operator+( difference_type n, zip_iterator rhs ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { rhs += n; return rhs; } friend constexpr zip_iterator operator-( zip_iterator lhs, difference_type n ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { lhs -= n; return lhs; } friend constexpr zip_iterator operator-( difference_type n, zip_iterator rhs ) - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { rhs -= n; return rhs; } constexpr difference_type operator-( zip_iterator const &rhs ) const - requires( RandomIteratorTag ) { + requires( RandomIteratorTag ) + { return std::get<0>( m_iters ) - std::get<0>( rhs.m_iters ); } }; @@ -377,8 +390,8 @@ namespace daw::pipelines { static constexpr std::size_t range_count = sizeof...( Ranges ); template - requires( requires { typename ZR::i_am_a_daw_zip_view_class; } ) // - friend struct pimpl::zip_iterator; + requires( requires { typename ZR::i_am_a_daw_zip_view_class; } ) + friend struct pimpl::zip_iterator; private: ranges_t m_ranges{ }; diff --git a/include/daw/split_buffer.h b/include/daw/split_buffer.h index bde5282c0..b209f2dc3 100644 --- a/include/daw/split_buffer.h +++ b/include/daw/split_buffer.h @@ -31,7 +31,8 @@ namespace daw::si_impl { template constexpr void swap_allocator( Alloc &a1, Alloc &a2 ) noexcept { swap_allocator( - a1, a2, + a1, + a2, std::bool_constant< std::allocator_traits::propagate_on_container_swap::value>{ } ); } @@ -117,8 +118,8 @@ namespace daw { } } - explicit constexpr split_buffer( split_buffer &&c ) // - noexcept( std::is_nothrow_move_constructible_v ) + explicit constexpr split_buffer( split_buffer &&c ) noexcept( + std::is_nothrow_move_constructible_v ) : first_( std::move( c.first_ ) ) , begin_( std::move( c.begin_ ) ) , end_( std::move( c.end_ ) ) @@ -146,11 +147,10 @@ namespace daw { } } - constexpr split_buffer &operator=( split_buffer &&c ) // - noexcept( - (alloc_traits::propagate_on_container_move_assignment::value and - std::is_nothrow_move_assignable_v) or - not alloc_traits::propagate_on_container_move_assignment::value ) { + constexpr split_buffer &operator=( split_buffer &&c ) noexcept( + (alloc_traits::propagate_on_container_move_assignment::value and + std::is_nothrow_move_assignable_v) or + not alloc_traits::propagate_on_container_move_assignment::value ) { clear( ); shrink_to_fit( ); first_ = c.first_; @@ -158,8 +158,9 @@ namespace daw { end_ = c.end_; end_cap( ) = c.end_cap( ); move_assign_alloc( - c, bool_constant< - alloc_traits::propagate_on_container_move_assignment::value>{ } ); + c, + bool_constant< + alloc_traits::propagate_on_container_move_assignment::value>{ } ); c.first_ = nullptr; c.begin_ = nullptr; c.end_ = nullptr; @@ -321,8 +322,8 @@ namespace daw { std::swap( end_cap( ), t.end_cap( ) ); } } - alloc_traits::construct( alloc( ), std::to_address( begin_ - 1 ), - std::move( x ) ); + alloc_traits::construct( + alloc( ), std::to_address( begin_ - 1 ), std::move( x ) ); --begin_; } @@ -345,8 +346,8 @@ namespace daw { std::swap( end_cap( ), t.end_cap( ) ); } } - alloc_traits::construct( alloc( ), std::to_address( end_ ), - std::move( x ) ); + alloc_traits::construct( + alloc( ), std::to_address( end_ ), std::move( x ) ); ++end_; } @@ -370,8 +371,8 @@ namespace daw { std::swap( end_cap( ), t.end_cap( ) ); } } - alloc_traits::construct( alloc( ), std::to_address( end_ ), - DAW_FWD( args )... ); + alloc_traits::construct( + alloc( ), std::to_address( end_ ), DAW_FWD( args )... ); ++end_; } @@ -418,8 +419,8 @@ namespace daw { auto const new_cap = std::max( 2 * old_cap, 8 ); split_buffer buf( new_cap, 0, a ); for( pointer p = begin_; p != end_; ++p, ++buf.end_ ) { - alloc_traits::construct( buf.alloc( ), std::to_address( buf.end_ ), - std::move( *p ) ); + alloc_traits::construct( + buf.alloc( ), std::to_address( buf.end_ ), std::move( *p ) ); } swap( buf ); } @@ -471,9 +472,9 @@ namespace daw { end_ = new_last; } - constexpr void swap( split_buffer &x ) // - noexcept( not alloc_traits::propagate_on_container_swap::value or - std::is_nothrow_swappable_v ) { + constexpr void swap( split_buffer &x ) noexcept( + not alloc_traits::propagate_on_container_swap::value or + std::is_nothrow_swappable_v ) { std::swap( first_, x.first_ ); std::swap( begin_, x.begin_ ); std::swap( end_, x.end_ ); diff --git a/include/daw/traits/daw_traits_is_a_type.h b/include/daw/traits/daw_traits_is_a_type.h index 1b739fcd6..1131304fe 100644 --- a/include/daw/traits/daw_traits_is_a_type.h +++ b/include/daw/traits/daw_traits_is_a_type.h @@ -51,24 +51,18 @@ namespace daw::traits { #undef GENERATE_IS_STD_CONTAINER2 template - using is_single_item_container = std::disjunction, - is_list, - is_set, - is_deque, - is_unordered_set>; + using is_single_item_container = + std::disjunction, is_list, is_set, is_deque, + is_unordered_set>; template inline constexpr bool is_single_item_container_v = is_single_item_container::value; template - using is_container = std::disjunction, - is_list, - is_set, - is_deque, - is_unordered_set, - is_map, - is_unordered_map>; + using is_container = + std::disjunction, is_list, is_set, is_deque, + is_unordered_set, is_map, is_unordered_map>; template inline constexpr bool is_container_v = is_container::value; diff --git a/include/daw/traits/daw_traits_is_ostream_like.h b/include/daw/traits/daw_traits_is_ostream_like.h index 50678a81f..0709d2a83 100644 --- a/include/daw/traits/daw_traits_is_ostream_like.h +++ b/include/daw/traits/daw_traits_is_ostream_like.h @@ -17,21 +17,18 @@ namespace daw::traits { template inline constexpr bool is_ostream_like_lite_v< - T, - std::void_t( ).fill( ) ), - decltype( std::declval( ).good( ) ), - decltype( std::declval( ).width( ) ), - decltype( std::declval( ).flags( ) )>> = true; + T, std::void_t( ).fill( ) ), + decltype( std::declval( ).good( ) ), + decltype( std::declval( ).width( ) ), + decltype( std::declval( ).flags( ) )>> = true; template inline constexpr bool has_write_member_v = false; template inline constexpr bool has_write_member_v< - T, - CharT, + T, CharT, std::void_t( ).write( std::declval( ), std::declval( ) ) )>> = true; diff --git a/include/daw/traits/daw_traits_nth_element.h b/include/daw/traits/daw_traits_nth_element.h index 60b02cd16..ae6c2c06b 100644 --- a/include/daw/traits/daw_traits_nth_element.h +++ b/include/daw/traits/daw_traits_nth_element.h @@ -32,7 +32,7 @@ namespace daw::traits { #else template using nth_element = typename decltype( nth_pack_element( - daw::traits::identity{}... ) )::type; + daw::traits::identity{ }... ) )::type; #endif template using nth_type = nth_element; diff --git a/include/daw/vector.h b/include/daw/vector.h index 3b44ae605..23a3e4c42 100644 --- a/include/daw/vector.h +++ b/include/daw/vector.h @@ -45,7 +45,8 @@ namespace daw::impl { using traits = std::allocator_traits; DAW_UNSAFE_BUFFER_FUNC_START while( end1 != begin1 ) { - traits::construct( a, std::to_address( end2 - 1 ), + traits::construct( a, + std::to_address( end2 - 1 ), #if defined( DAW_USE_EXCEPTIONS ) std::move_if_noexcept( *--end1 ) #else @@ -67,7 +68,8 @@ namespace daw::impl { using traits_t = std::allocator_traits; DAW_UNSAFE_BUFFER_FUNC_START for( ; begin1 != end1; ++begin1, (void)++begin2 ) { - traits_t::construct( a, std::to_address( begin2 ), + traits_t::construct( a, + std::to_address( begin2 ), #if defined( DAW_USE_EXCEPTIONS ) std::move_if_noexcept( *begin1 ) #else @@ -104,9 +106,8 @@ namespace daw { not ResizeAndOverwriteOperationAlloc; template - inline constexpr bool has_slow_distance_v = requires { - typename T::slow_distance; - }; + inline constexpr bool has_slow_distance_v = + requires { typename T::slow_distance; }; template> struct vector { @@ -138,8 +139,8 @@ namespace daw { public: explicit vector( ) = default; - explicit constexpr vector( allocator_type const &a ) // - noexcept( std::is_nothrow_copy_constructible::value ) + explicit constexpr vector( allocator_type const &a ) noexcept( + std::is_nothrow_copy_constructible::value ) : m_endcap_( nullptr, a ) {} explicit constexpr vector( size_type n ) { @@ -194,9 +195,9 @@ namespace daw { } template - requires( constructible_from> ) // - explicit constexpr vector( InputIterator first, InputIterator last ) { + requires( + constructible_from> ) + explicit constexpr vector( InputIterator first, InputIterator last ) { DAW_UNSAFE_BUFFER_FUNC_START for( ; first != last; ++first ) { @@ -206,10 +207,10 @@ namespace daw { } template - requires( constructible_from> ) // - explicit constexpr vector( InputIterator first, InputIterator last, - allocator_type const &a ) + requires( + constructible_from> ) + explicit constexpr vector( InputIterator first, InputIterator last, + allocator_type const &a ) : m_endcap_( nullptr, a ) { DAW_UNSAFE_BUFFER_FUNC_START @@ -220,10 +221,10 @@ namespace daw { } template - requires( not has_slow_distance_v and - constructible_from> ) // - explicit constexpr vector( ForwardIterator first, ForwardIterator last ) { + requires( + not has_slow_distance_v and + constructible_from> ) + explicit constexpr vector( ForwardIterator first, ForwardIterator last ) { auto const n = static_cast( std::distance( first, last ) ); if( n > 0 ) { @@ -233,11 +234,11 @@ namespace daw { } template - requires( not has_slow_distance_v and - constructible_from> ) // - explicit constexpr vector( ForwardIterator first, ForwardIterator last, - allocator_type const &a ) + requires( + not has_slow_distance_v and + constructible_from> ) + explicit constexpr vector( ForwardIterator first, ForwardIterator last, + allocator_type const &a ) : m_endcap_( nullptr, a ) { auto const n = static_cast( std::distance( first, last ) ); if( n > 0 ) { @@ -324,21 +325,21 @@ namespace daw { assign( il.begin( ), il.end( ) ); return *this; } - constexpr vector &operator=( vector &&x ) // - noexcept( - impl::noexcept_move_assign_container_v ) { + constexpr vector &operator=( vector &&x ) noexcept( + impl::noexcept_move_assign_container_v ) { move_assign( - x, std::bool_constant< - alloc_traits::propagate_on_container_move_assignment::value>{ } ); + x, + std::bool_constant< + alloc_traits::propagate_on_container_move_assignment::value>{ } ); return *this; } template - requires( constructible_from> ) // - void assign( InputIterator first, InputIterator last ) { + requires( + constructible_from> ) + void assign( InputIterator first, InputIterator last ) { clear( ); DAW_UNSAFE_BUFFER_FUNC_START for( ; first != last; ++first ) { @@ -348,10 +349,10 @@ namespace daw { } template - requires( not has_slow_distance_v and - constructible_from> ) // - constexpr void assign( ForwardIterator first, ForwardIterator last ) { + requires( + not has_slow_distance_v and + constructible_from> ) + constexpr void assign( ForwardIterator first, ForwardIterator last ) { auto const new_size = static_cast( std::distance( first, last ) ); if( new_size <= capacity( ) ) { @@ -713,9 +714,9 @@ namespace daw { template requires( - constructible_from> ) // - constexpr iterator insert( const_iterator position, InputIterator first, - InputIterator last ) { + constructible_from> ) + constexpr iterator insert( const_iterator position, InputIterator first, + InputIterator last ) { difference_type off = position - begin( ); pointer p = m_begin + off; allocator_type &a = alloc( ); @@ -742,17 +743,18 @@ namespace daw { #endif } p = std::rotate( p, old_last, m_end ); - insert( make_iter( p ), std::make_move_iterator( v.begin( ) ), + insert( make_iter( p ), + std::make_move_iterator( v.begin( ) ), std::make_move_iterator( v.end( ) ) ); return begin( ) + off; } template - requires( not has_slow_distance_v and - constructible_from> ) // - constexpr iterator insert( const_iterator position, ForwardIterator first, - ForwardIterator last ) { + requires( + not has_slow_distance_v and + constructible_from> ) + constexpr iterator insert( const_iterator position, ForwardIterator first, + ForwardIterator last ) { pointer p = m_begin + ( position - begin( ) ); difference_type n = std::distance( first, last ); if( n > 0 ) { @@ -776,7 +778,8 @@ namespace daw { allocator_type &a = alloc( ); auto v = split_buffer( recommend( static_cast( ssize( ) + n ) ), - static_cast( p - m_begin ), a ); + static_cast( p - m_begin ), + a ); v.construct_at_end( first, last ); p = swap_out_circular_buffer( v, p ); } @@ -927,7 +930,8 @@ namespace daw { std::swap( m_begin, other.m_begin ); std::swap( m_end, other.m_end ); std::swap( endcap( ), other.endcap( ) ); - swap_allocator( alloc( ), other.alloc( ), + swap_allocator( alloc( ), + other.alloc( ), std::bool_constant< alloc_traits::propagate_on_container_swap::value>{ } ); } @@ -996,9 +1000,9 @@ namespace daw { } template - requires( not has_slow_distance_v ) // - constexpr void construct_at_end( ForwardIterator first, - ForwardIterator last, size_type n ) { + requires( not has_slow_distance_v ) + constexpr void construct_at_end( ForwardIterator first, + ForwardIterator last, size_type n ) { ConstructTransaction tx( *this, n ); impl::construct_range_forward( alloc( ), first, last, tx.pos ); } @@ -1052,8 +1056,8 @@ namespace daw { constexpr void swap_out_circular_buffer( split_buffer &v ) { - impl::construct_backward_with_exception_guarantees( alloc( ), m_begin, - m_end, v.begin_ ); + impl::construct_backward_with_exception_guarantees( + alloc( ), m_begin, m_end, v.begin_ ); std::swap( m_begin, v.begin_ ); std::swap( m_end, v.end_ ); std::swap( endcap( ), v.end_cap( ) ); @@ -1064,10 +1068,10 @@ namespace daw { swap_out_circular_buffer( split_buffer &v, pointer p ) { pointer r = v.begin_; - impl::construct_backward_with_exception_guarantees( alloc( ), m_begin, p, - v.begin_ ); - impl::construct_forward_with_exception_guarantees( alloc( ), p, m_end, - v.end_ ); + impl::construct_backward_with_exception_guarantees( + alloc( ), m_begin, p, v.begin_ ); + impl::construct_forward_with_exception_guarantees( + alloc( ), p, m_end, v.end_ ); std::swap( m_begin, v.begin_ ); std::swap( m_end, v.end_ ); std::swap( endcap( ), v.end_cap( ) ); @@ -1083,16 +1087,15 @@ namespace daw { ConstructTransaction tx( *this, static_cast( from_e - i ) ); for( pointer pos = tx.pos; i < from_e; ++i, (void)++pos, tx.pos = pos ) { - alloc_traits::construct( alloc( ), std::to_address( pos ), - std::move( *i ) ); + alloc_traits::construct( + alloc( ), std::to_address( pos ), std::move( *i ) ); } } std::move_backward( from_s, from_s + n, old_last ); } - constexpr void move_assign( vector &c, - std::false_type ) // - noexcept( alloc_traits::is_always_equal::value ) { + constexpr void move_assign( vector &c, std::false_type ) noexcept( + alloc_traits::is_always_equal::value ) { if( alloc( ) != c.alloc( ) ) { using move_it_t = std::move_iterator; assign( move_it_t( c.begin( ) ), move_it_t( c.end( ) ) ); @@ -1101,8 +1104,8 @@ namespace daw { } } - constexpr void move_assign( vector &c, std::true_type ) // - noexcept( std::is_nothrow_move_assignable_v ) { + constexpr void move_assign( vector &c, std::true_type ) noexcept( + std::is_nothrow_move_assignable_v ) { vdeallocate( ); move_assign_alloc( c ); // this can throw m_begin = c.m_begin; @@ -1136,8 +1139,8 @@ namespace daw { auto v = split_buffer( recommend( size( ) + 1 ), size( ), a ); // v.emplace_back(DAW_FWD(args)...); - alloc_traits::construct( a, std::to_address( v.end_ ), - DAW_FWD( args )... ); + alloc_traits::construct( + a, std::to_address( v.end_ ), DAW_FWD( args )... ); DAW_UNSAFE_BUFFER_FUNC_START ++v.end_; DAW_UNSAFE_BUFFER_FUNC_STOP @@ -1167,8 +1170,8 @@ namespace daw { template constexpr void construct_one_at_end( Args &&...args ) { ConstructTransaction tx( *this, 1 ); - alloc_traits::construct( alloc( ), std::to_address( tx.pos ), - DAW_FWD( args )... ); + alloc_traits::construct( + alloc( ), std::to_address( tx.pos ), DAW_FWD( args )... ); DAW_UNSAFE_BUFFER_FUNC_START ++tx.pos; DAW_UNSAFE_BUFFER_FUNC_STOP @@ -1202,16 +1205,18 @@ namespace daw { constexpr void copy_assign_alloc( vector const &c ) { copy_assign_alloc( - c, std::bool_constant< - alloc_traits::propagate_on_container_copy_assignment::value>{ } ); + c, + std::bool_constant< + alloc_traits::propagate_on_container_copy_assignment::value>{ } ); } constexpr void move_assign_alloc( vector &c ) noexcept( not alloc_traits::propagate_on_container_move_assignment::value or std::is_nothrow_move_assignable_v ) { move_assign_alloc( - c, std::bool_constant< - alloc_traits::propagate_on_container_move_assignment::value>{ } ); + c, + std::bool_constant< + alloc_traits::propagate_on_container_move_assignment::value>{ } ); } [[noreturn]] void throw_length_error( ) const { @@ -1233,8 +1238,8 @@ namespace daw { constexpr void copy_assign_alloc( vector const &, std::false_type ) {} - constexpr void move_assign_alloc( vector &c, std::true_type ) // - noexcept( std::is_nothrow_move_assignable_v ) { + constexpr void move_assign_alloc( vector &c, std::true_type ) noexcept( + std::is_nothrow_move_assignable_v ) { alloc( ) = std::move( c.alloc( ) ); } @@ -1255,8 +1260,8 @@ namespace daw { [[nodiscard]] friend constexpr bool operator<( vector const &x, vector const &y ) { - return std::lexicographical_compare( x.data( ), x.data_end( ), y.data( ), - y.data_end( ) ); + return std::lexicographical_compare( + x.data( ), x.data_end( ), y.data( ), y.data_end( ) ); } [[nodiscard]] friend constexpr bool operator>( vector const &x, diff --git a/include/daw/wrap_iter.h b/include/daw/wrap_iter.h index 1ed443e11..96525e372 100644 --- a/include/daw/wrap_iter.h +++ b/include/daw/wrap_iter.h @@ -39,8 +39,8 @@ namespace daw { template requires( std::is_convertible_v and - not std::is_same_v ) // - constexpr wrap_iter( wrap_iter const &u ) noexcept + not std::is_same_v ) + constexpr wrap_iter( wrap_iter const &u ) noexcept : i( u.base( ) ) {} constexpr reference operator*( ) const noexcept { From d94ad3835d0f76b98200dffbf7bb2705188e1495 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 25 Sep 2026 16:07:59 -0400 Subject: [PATCH 2/4] Add `is_explicitly_convertible_v` trait and accompanying tests --- .../daw_traits_is_explicitly_convertible.h | 31 +++++ tests/CMakeLists.txt | 1 + ..._traits_is_explicitly_convertible_test.cpp | 111 ++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 include/daw/traits/daw_traits_is_explicitly_convertible.h create mode 100644 tests/daw_traits_is_explicitly_convertible_test.cpp diff --git a/include/daw/traits/daw_traits_is_explicitly_convertible.h b/include/daw/traits/daw_traits_is_explicitly_convertible.h new file mode 100644 index 000000000..aedd1e828 --- /dev/null +++ b/include/daw/traits/daw_traits_is_explicitly_convertible.h @@ -0,0 +1,31 @@ +// Copyright (c) Darrell Wright +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/beached/header_libraries +// + +#pragma once + +#include "daw/daw_cpp_feature_check.h" + +#include +#include + +namespace daw { +#if defined( DAW_HAS_CPP20_CONCEPTS ) + template + inline constexpr bool is_explicitly_convertible_v = requires { + static_cast( std::declval( ) ); + }; +#else + template + inline constexpr bool is_explicitly_convertible_v = false; + + template + inline constexpr bool is_explicitly_convertible_v< + From, To, + std::void_t( std::declval( ) ) )>> = true; +#endif +} // namespace daw diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index db394c886..906cfbce6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -100,6 +100,7 @@ set( TEST_SOURCES daw_string_concat_test.cpp daw_string_view2_test.cpp daw_take_test.cpp + daw_traits_is_explicitly_convertible_test.cpp daw_traits_test.cpp daw_tuple_helper_test.cpp daw_tuple_test.cpp diff --git a/tests/daw_traits_is_explicitly_convertible_test.cpp b/tests/daw_traits_is_explicitly_convertible_test.cpp new file mode 100644 index 000000000..6f6330e58 --- /dev/null +++ b/tests/daw_traits_is_explicitly_convertible_test.cpp @@ -0,0 +1,111 @@ +// Copyright (c) Darrell Wright +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/beached/header_libraries +// + +#include + +#include +#include +#include + +using daw::is_explicitly_convertible_v; + +namespace { + struct Explicit { + explicit Explicit( int ) {} + }; + + struct ExplicitOp { + explicit operator int( ) const { + return 0; + } + }; + + struct RvalueOp { + operator int( ) && { + return 0; + } + }; + + struct MoveOnly { + MoveOnly( ) = default; + MoveOnly( MoveOnly && ) = default; + MoveOnly( MoveOnly const & ) = delete; + }; + + struct Base { + virtual ~Base( ) = default; + }; + struct Derived : Base {}; + + struct Abstract { + virtual void f( ) = 0; + }; + + enum class Color { red }; + + struct Unrelated {}; +} // namespace + +// Arithmetic and enums +static_assert( is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); + +// Explicit constructors / conversion operators, which is_convertible rejects +static_assert( is_explicitly_convertible_v ); +static_assert( not std::is_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( not std::is_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( not std::is_convertible_v ); +static_assert( not is_explicitly_convertible_v ); + +// From is treated as an rvalue, matching std::is_convertible +static_assert( is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); +static_assert( + is_explicitly_convertible_v, std::unique_ptr> ); +static_assert( not is_explicitly_convertible_v const &, + std::unique_ptr> ); + +// References +static_assert( is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); + +// Pointers and class hierarchies +static_assert( is_explicitly_convertible_v ); +static_assert( not std::is_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); + +// void +static_assert( is_explicitly_convertible_v ); +static_assert( is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); + +// Non-convertible +static_assert( not is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); +static_assert( not is_explicitly_convertible_v ); + +int main( ) {} From 7b35245d5b563351e2f505303793ccdd09400ba7 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 25 Sep 2026 16:20:56 -0400 Subject: [PATCH 3/4] Add default virtual destructor to `Abstract` in test --- tests/daw_traits_is_explicitly_convertible_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/daw_traits_is_explicitly_convertible_test.cpp b/tests/daw_traits_is_explicitly_convertible_test.cpp index 6f6330e58..8a395957d 100644 --- a/tests/daw_traits_is_explicitly_convertible_test.cpp +++ b/tests/daw_traits_is_explicitly_convertible_test.cpp @@ -44,6 +44,7 @@ namespace { struct Abstract { virtual void f( ) = 0; + virtual ~Abstract( ) = default; }; enum class Color { red }; From 06248d9b889905053283e549af7af4d59cfc0086 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 25 Sep 2026 16:27:37 -0400 Subject: [PATCH 4/4] Add static assertions to suppress unused warnings in `MoveOnly` test --- tests/daw_traits_is_explicitly_convertible_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/daw_traits_is_explicitly_convertible_test.cpp b/tests/daw_traits_is_explicitly_convertible_test.cpp index 8a395957d..791ebc1dd 100644 --- a/tests/daw_traits_is_explicitly_convertible_test.cpp +++ b/tests/daw_traits_is_explicitly_convertible_test.cpp @@ -36,6 +36,10 @@ namespace { MoveOnly( MoveOnly && ) = default; MoveOnly( MoveOnly const & ) = delete; }; + // These get rid of unused warnings on some compilers + static_assert( not std::is_copy_constructible_v ); + static_assert( std::is_move_constructible_v ); + static_assert( std::is_default_constructible_v ); struct Base { virtual ~Base( ) = default;