Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-ranges.H File Reference

C++20 Ranges support and adaptors for Aleph-w containers. More...

#include <type_traits>
#include <utility>
#include <tuple>
#include <functional>
Include dependency graph for ah-ranges.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::detail
 

Macros

#define ALEPH_HAS_RANGES   0
 
#define ALEPH_HAS_STRIDE   0
 
#define ALEPH_HAS_REPEAT   0
 
#define ALEPH_HAS_ZIP   0
 
#define ALEPH_HAS_ENUMERATE   0
 

Functions

template<typename Container , typename Pred >
bool Aleph::detail::fallback_all_of (const Container &c, Pred &&pred)
 
template<typename Container , typename Pred >
bool Aleph::detail::fallback_any_of (const Container &c, Pred &&pred)
 
template<typename Container , typename Pred >
bool Aleph::detail::fallback_none_of (const Container &c, Pred &&pred)
 
template<typename Container , typename T , typename BinaryOp >
constexpr T Aleph::detail::ranges_fold_left (Container &&c, T init, BinaryOp &&op)
 Fallback fold_left using range-based for loop.
 
template<typename Container , typename Pred >
bool Aleph::detail::ranges_all_of (const Container &c, Pred &&pred)
 Fallback all_of using range-based for loop.
 
template<typename Container , typename Pred >
bool Aleph::detail::ranges_any_of (const Container &c, Pred &&pred)
 Fallback any_of using range-based for loop.
 
template<typename Container , typename Pred >
bool Aleph::detail::ranges_none_of (const Container &c, Pred &&pred)
 Fallback none_of using range-based for loop.
 
template<typename Container , typename Pred >
auto Aleph::detail::ranges_count_if (const Container &c, Pred &&pred)
 Fallback count_if using range-based for loop.
 

Detailed Description

C++20 Ranges support and adaptors for Aleph-w containers.

This header provides:

  • Range adaptors for Aleph containers (DynList, DynArray, etc.)
  • Internal utilities using std::ranges for improved performance
  • Lazy range views compatible with Aleph containers

COMPILER AND STANDARD LIBRARY REQUIREMENTS

Minimum Requirements

  • C++20 or later (-std=c++20)
  • GCC 12+ with libstdc++, OR
  • Clang 14+ with libc++ (-stdlib=libc++), OR
  • MSVC 19.29+

IMPORTANT: Clang + libstdc++ Incompatibility

Clang 14-15 with libstdc++ (GCC's standard library) has BROKEN std::ranges support. The combination fails to satisfy iterator concepts correctly, causing compilation errors like:

  • "no matching function for call to '__begin'"
  • "constraints not satisfied for alias template 'sentinel_t'"
  • "invalid operands to binary expression"

Solutions (choose one):

  1. Use libc++ with Clang (RECOMMENDED):
    clang++ -std=c++20 -stdlib=libc++ -lc++abi myfile.cpp
    STL namespace.
  2. Use GCC instead of Clang:
    g++ -std=c++20 myfile.cpp
  3. Upgrade to Clang 16+ (has better libstdc++ compatibility)

Why does this happen?

libc++ is Clang's native C++ standard library with full std::ranges support. libstdc++ is GCC's library; older Clang versions have subtle incompatibilities with its iterator concept implementations.


Usage Example

#include <ah-ranges.H>
#include <htlist.H>
DynList<int> list = {1, 2, 3, 4, 5};
// Use with std::ranges algorithms
bool has_even = std::ranges::any_of(list, [](int x) { return x % 2 == 0; });
// Use with views
for (auto x : list | std::views::filter([](int x) { return x % 2 == 0; }))
std::cout << x << " "; // prints: 2 4
// Use internal lazy range generation
for (auto x : Aleph::lazy_range(1, 10))
std::cout << x << " "; // prints: 1 2 3 4 5 6 7 8 9
C++20 Ranges support and adaptors for Aleph-w containers.
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
Container2< typename Container1::Item_Type > filter(Container1 &container, Operation &operation)
Filter elements that satisfy operation.
Note
The public API of ahFunctional.H is preserved. This header provides internal optimizations and additional range-based utilities.
Author
Leandro Rabindranath Leon

Definition in file ah-ranges.H.

Macro Definition Documentation

◆ ALEPH_HAS_ENUMERATE

#define ALEPH_HAS_ENUMERATE   0

Definition at line 166 of file ah-ranges.H.

◆ ALEPH_HAS_RANGES

#define ALEPH_HAS_RANGES   0

Definition at line 141 of file ah-ranges.H.

◆ ALEPH_HAS_REPEAT

#define ALEPH_HAS_REPEAT   0

Definition at line 154 of file ah-ranges.H.

◆ ALEPH_HAS_STRIDE

#define ALEPH_HAS_STRIDE   0

Definition at line 148 of file ah-ranges.H.

◆ ALEPH_HAS_ZIP

#define ALEPH_HAS_ZIP   0

Definition at line 160 of file ah-ranges.H.