Code Monkey home page Code Monkey logo

cjdb-ranges's Introduction

cjdb-ranges

cjdb-ranges is a C++20 implementation for range abstractions. It prioritises the implementation for C++20 ranges using the clang-concepts-monorepo fork of Clang, but supports both libc++ and libstdc++.

What are 'C++20 ranges'?

The term 'C++20 ranges' is used to refer to range abstractions that can be found in standard C++20. Most of this content can be found in the [concepts], [iterators], [ranges], and [algorithms] clauses of the C++20 specification, but a handful can be found in the [function.objects] subclause as well.

Installing cjdb-ranges

Please see doc/install.md.

Getting started

Please see doc/getting-started.md.

cjdb-ranges's People

Contributors

cjdb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cjdb-ranges's Issues

Add a test suite for checking subsumption hierarchies

Is your feature request related to a problem? Please describe.
The current mechanism for checking C2 subsumes C1 is completely ad-hoc. It'd be great for there to be a more formal way of checking this.

Describe the solution you'd like
Cleanly checking for subsumption may never be possible at a language level, but we might be able to force variable templates to do the check with well-documented values.

// Example 1
enum class subsumes {
   nothing,
   // public concept names here
};

template<typename...>
inline constexpr auto regular_hierarchy = subsumes::nothing;

template<destructible T>
inline constexpr auto regular_hierarchy<T> = subsumes::destructible;

template<default_initializable T>
inline constexpr auto regular_hierarchy<T> = subsumes::default_initializable;

template<move_constructible T>
inline constexpr auto regular_hierarchy<T> = subsumes::move_constructible;

template<copy_constructible T>
inline constexpr auto regular_hierarchy<T> = subsumes::copy_constructible;

template<swappable T>
inline constexpr auto regular_hierarchy<T> = subsumes::swappable;

template<movable T>
inline constexpr auto regular_hierarchy<T> = subsumes::movable;

template<copyable T>
inline constexpr auto regular_hierarchy<T> = subsumes::copyable;

template<semiregular T>
inline constexpr auto regular_hierarchy<T> = subsumes::semiregular;

template<equality_comparable T>
inline constexpr auto regular_hierarchy<T> = subsumes::equality_comparable;

template<regular T>
inline constexpr auto regular_hierarchy<T> = subsumes::regular;

static_assert(regular_hierarchy<std::mutex> == subsumes::default_initializable);
static_assert(regular_hierarchy<std::span<int>> == subsumes::semiregular);
static_assert(regular_hierarchy<int> == subsumes::regular);

Describe alternatives you've considered
No alternatives at present.

Additional context
The solution needs to be carefully curated, because we'll run into ambiguity problems otherwise.

// Example 2
template<typename...>
inline constexpr auto check_subsumption = subsumes::nothing;

template<semiregular T>
inline constexpr auto check_subsumption<T> = subsumes::semiregular;

template<equality_comparable T>
inline constexpr auto check_subsumption<T> = subsumes::equality_comparable;

template<regular T>
inline constexpr auto check_subsumption = subsumes::regular;

template<totally_ordered T>
inline constexpr auto check_subsumption = subsumes::totally_ordered;

static_assert(check_subsumption<int> == subsumes::regular); // error

In Example 2, we hit the problem that regular<int> and totally_ordered<int> are both satisfied, and thus specialisation becomes ambiguous. While it might be a valid compiler test to add a more specialised check_subsumption that requires both concepts, it doesn't benefit this test suite, which wants to check that regular subsumes semiregular and equality_comparable.

Move headers from cjdb/detail/* to cjdb/* if they aren't a detail

Is your feature request related to a problem? Please describe.
It would be nice for users to be able to explicitly specify the types that they use. For example:

#include "cjdb/iterator/reverse_iterator.hpp"

As opposed to

#include "cjdb/iterator.hpp" // reverse_iterator

Describe the solution you'd like
Move all non-detail headers out of the detail directory.

[BUG] ranges::begin and ranges::end not to spec

Describe the bug
Per the adoption of [P1870], ranges::begin and ranges::end depend on enable_safe_range, but this library doesn't have enable_safe_range.

Acceptance criteria
ranges::begin and ranges::end should both depend on enable_safe_range, and there should be an added test-case.

Add range comparison objects

Is your feature request related to a problem? Please describe.
C++20 adds constrained comparison objects. Part of having a conforming implementation of Standard ranges is to support range.cmp.

This will add:

  • cjdb::ranges::equal_to
  • cjdb::ranges::not_equal_to
  • cjdb::ranges::less
  • cjdb::ranges::less_equal
  • cjdb::ranges::greater
  • cjdb::ranges::greater_equal

Add feature support for concepts in CMake

Is your feature request related to a problem? Please describe.
Manually trying get GCC to compile with concept bool is tedious and error prone, and should be automated.

Describe the solution you'd like
It would be nice if this project had a CMake script that could auto detect if a compiler requires concept or concept bool when supporting concepts.

Additional context
See cmake/FindSanitizer.cmake for an example of how this might be set up.

Replace CJDB_NOEXCEPT_RETURN with proposed CJDB_DEDUCE_NOEXCEPT

template<typename T>
constexpr auto operator()(T&& t) const
CJDB_DEDUCE_NOEXCEPT({
   return process(t);
})

is much easier to grok and makes the function feel more natural than what is currently in place.

Proposed resolution

  1. Replace definition of CJDB_NOEXCEPT_RETURN with
#define CJDB_INJECT_LAMBDA(...) [&] __VA_ARGS__ ()

#define CJDB_DEDUCE_NOEXCEPT(...)                   \
noexcept(noexcept(CJDB_INJECT_LAMBDA(__VA_ARGS__))) \
{ return CJDB_INJECT_LAMBDA(__VA_ARGS__); }
  1. Replace all occurrences of CJDB_NOEXCEPT_RETURN with CJDB_DEDUCE_NOEXCEPT.

Add support for vcpkg

Is your feature request related to a problem? Please describe.
Not everyone uses Conan. It'd be nice if there was an alternative package manager that's more lightweight, and this will also remove the dependency on Python that increases the size of Docker images.

Describe the solution you'd like
Add support for vcpkg, whilst keeping support for Conan.

Describe alternatives you've considered
No alternatives considered: other package managers should be requested per alternative feature requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.