Skip to content

Commit

Permalink
Merge pull request #518 from beached/v2
Browse files Browse the repository at this point in the history
removed functional from string_view 2
  • Loading branch information
beached authored Jan 8, 2024
2 parents 89e330c + 38764bc commit 6f85714
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
cmake_minimum_required( VERSION 3.14 )

project( "daw-header-libraries"
VERSION "2.98.3"
VERSION "2.98.4"
DESCRIPTION "Various headers"
HOMEPAGE_URL "https://github.com/beached/header_libraries"
LANGUAGES C CXX
Expand Down
4 changes: 1 addition & 3 deletions include/daw/daw_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@
#define DAW_NO_UNIQUE_ADDRESS [[no_unique_address]]
#endif

#if defined( __clang__ )
#if DAW_HAS_CLANG_VER_GTE( 13, 0 )
#define DAW_PREF_NAME( ... ) clang::preferred_name( __VA_ARGS__ )
//#elif defined( __GNUC__ )
//#define DAW_PREF_NAME( ... ) gnu::preferred_name( __VA_ARGS__ )
#else
#define DAW_PREF_NAME( ... )
#endif
46 changes: 37 additions & 9 deletions include/daw/daw_string_view2.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include <cstddef>
#include <cstdlib>
#include <functional>
#include <iterator>
#include <stdexcept>
#include <type_traits>
Expand Down Expand Up @@ -112,6 +111,34 @@ namespace daw {
namespace sv2 {

namespace sv2_details {
#if defined( __cpp_static_call_operator )
#if __cpp_static_call_operator >= 202207L
#define DAW_SV2_HAS_STATIC_CALL_OP
#endif
#endif
struct less {
template<typename T, typename U>
#if defined( DAW_SV2_HAS_STATIC_CALL_OP )
#if DAW_HAS_CLANG_VER_GTE( 16, 0 )
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++23-extensions"
#endif
DAW_ATTRIB_INLINE static constexpr bool
operator( )( T const &lhs, U const &rhs ) noexcept {
return lhs < rhs;
}

#if DAW_HAS_CLANG_VER_GTE( 16, 0 )
#pragma clang diagnostic pop
#endif
#else
DAW_ATTRIB_INLINE constexpr bool
operator( )( T const &lhs, U const &rhs ) const noexcept {
return lhs < rhs;
}
#endif
};

template<typename InputIt, typename ForwardIt, typename BinaryPredicate>
[[nodiscard]] constexpr InputIt
find_first_of( InputIt first, InputIt last, ForwardIt s_first,
Expand Down Expand Up @@ -1564,7 +1591,7 @@ namespace daw {
}

public:
template<typename Compare = std::less<void>, string_view_bounds_type BL,
template<typename Compare = sv2_details::less, string_view_bounds_type BL,
string_view_bounds_type BR>
[[nodiscard]] static constexpr int
compare( basic_string_view<CharT, BL> lhs,
Expand Down Expand Up @@ -1600,51 +1627,52 @@ namespace daw {
return ret;
}

template<typename Compare = std::less<>, string_view_bounds_type B>
template<typename Compare = sv2_details::less, string_view_bounds_type B>
[[nodiscard]] constexpr int compare( basic_string_view<CharT, B> rhs,
Compare cmp = Compare{ } ) const {
return compare(
*this, basic_string_view( std::data( rhs ), std::size( rhs ) ), cmp );
}

template<typename Compare = std::less<>, typename StringView,
template<typename Compare = sv2_details::less, typename StringView,
DAW_REQ_CONTIG_CHAR_RANGE( StringView, CharT )>
[[nodiscard]] constexpr int compare( StringView &&rhs,
Compare cmp = Compare{ } ) const {
return compare(
*this, basic_string_view( std::data( rhs ), std::size( rhs ) ), cmp );
}

template<typename Compare = std::less<>, std::size_t N>
template<typename Compare = sv2_details::less, std::size_t N>
[[nodiscard]] constexpr int compare( CharT const ( &rhs )[N],
Compare cmp = Compare{ } ) const {
return compare( *this, basic_string_view( rhs, N - 1 ), cmp );
}

template<typename Compare = std::less<>>
template<typename Compare = sv2_details::less>
constexpr int compare( size_type pos1, size_type count1,
basic_string_view v,
Compare cmp = Compare{ } ) const {
return compare( substr( pos1, count1 ), v, cmp );
}

template<typename Compare = std::less<>, string_view_bounds_type Bounds>
template<typename Compare = sv2_details::less,
string_view_bounds_type Bounds>
[[nodiscard]] constexpr int compare( size_type pos1, size_type count1,
basic_string_view<CharT, Bounds> v,
size_type pos2, size_type count2,
Compare cmp = Compare{ } ) const {
return compare( substr( pos1, count1 ), v.substr( pos2, count2 ), cmp );
}

template<typename Compare = std::less<>>
template<typename Compare = sv2_details::less>
[[nodiscard]] constexpr int compare( size_type pos1, size_type count1,
const_pointer s,
Compare cmp = Compare{ } ) const {
return compare( substr( pos1, count1 ),
basic_string_view<CharT, BoundsType>( s ), cmp );
}

template<typename Compare = std::less<>>
template<typename Compare = sv2_details::less>
[[nodiscard]] constexpr int compare( size_type pos1, size_type count1,
const_pointer s, size_type count2,
Compare cmp = Compare{ } ) const {
Expand Down
9 changes: 6 additions & 3 deletions tests/daw_zipcontainer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ int main( ) {
auto a = std::vector{ 1, 2, 3 };
auto b = std::vector{ 9, 8, 7 };
auto z = daw::zip_container( a, b );
for( auto &&item : z ) {
if( std::apply( []( auto const &l, auto const &r ) { return l + r; },
item ) != 10 ) {
for( auto item : z ) {
if( std::apply(
[]( auto const &l, auto const &r ) {
return l + r;
},
item ) != 10 ) {
std::abort( );
}
}
Expand Down

0 comments on commit 6f85714

Please sign in to comment.