Skip to content
Snippets Groups Projects

Add support for C++20 concepts

Closed Santiago Ospina De Los Ríos requested to merge feature/standard-concepts-support into master
3 unresolved threads
  • Some compilers already have support for concepts, hence, it would be a good idea to provide some basic compiler checks to enable it through DUNE.
  • Additionally, since some compilers do not provide the concepts library (e.g. clang), some concepts are provided as a fallback implementation.

In particular, this would enable one of my two Grid concept implementations for those using C++20.

I tested this with clang-11. Pipelines for supported compilers seem to be passing.

Usage: dune-grid!377 (merged)

Edited by Santiago Ospina De Los Ríos

Merge request reports

Approval is optional
Test summary results are being parsed

Closed by Santiago Ospina De Los RíosSantiago Ospina De Los Ríos 2 years ago (May 28, 2022 9:52am UTC)

Merge details

  • The changes were not merged into master.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 #ifndef DUNE_COMMON_STD_CONCEPTS_HH
2 #define DUNE_COMMON_STD_CONCEPTS_HH
3
4 // This header assumes that concepts are availalbe
5
6 #if __cpp_lib_concepts >= 201806L
  • 16 concept name = std::name<T>;
    17
    18 #define DUNE_CONCEPT_ALIAS_2(name) \
    19 template<class T0, class T1> \
    20 concept name = std::name<T0,T1>;
    21
    22 #define DUNE_CONCEPT_ALIAS_1_VAR(name) \
    23 template<class T, class... Args> \
    24 concept name = std::name<T,Args...>;
    25
    26 DUNE_CONCEPT_ALIAS_2(convertible_to)
    27 DUNE_CONCEPT_ALIAS_1(destructible)
    28 DUNE_CONCEPT_ALIAS_1_VAR(constructible_from)
    29 DUNE_CONCEPT_ALIAS_1(default_initializable)
    30 DUNE_CONCEPT_ALIAS_1(move_constructible)
    31 DUNE_CONCEPT_ALIAS_1(copy_constructible)
    • I'm not a big fan of these macros. If you define the concepts directly using std concepts, it would be shorter in the number of line. And it acts as a documentation of the template parameters by its name, directly.

    • Good point, but I guess it depends on how many concepts you expect to put here :sweat_smile:. The ranges library uses quite an amount of them for example, then handwriting them would be tedious.

      Btw, I just did this MR in order to share how I got the Grid concept implementation to work. So my intention is not that this file grows to contain all the concepts in the standard library.

    • Please register or sign in to reply
  • I have rebased to master to allow the gitlab-ci to be run (there was a change necessary in the first lines of that yml file, due to a change in the gitlab server.

  • added 1 commit

    • 5e5922df - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • added 1 commit

    • 8343adfe - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • added 1 commit

    • 8ff9420b - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • Simon Praetorius mentioned in merge request !953 (closed)

    mentioned in merge request !953 (closed)

  • Closing as this got outdated and not so relevant. See https://gitlab.dune-project.org/santiago.ospina/dune-concepts for a more up to date version.

  • Santiago Ospina De Los Ríos changed the description

    changed the description

  • Please register or sign in to reply
    Loading