-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a first step towards making QLever compile with C++17. If the compile-time flag `QLEVER_CPP_17` is set, use Eric Niebler's `range-v3` library as a drop-in replacement for `std::ranges`. In the code, we simply write `ql::ranges` instead of `std::ranges` in most places. Some places need special treatment. For example, where `std::ranges` was used as a C++20 concept, we now use the macros `CPP_template` and `CPP_and` (also from the `range-v3` library), which does the right thing for both C++20 and C++17.
- Loading branch information
Showing
163 changed files
with
1,258 additions
and
1,026 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2024, University of Freiburg, | ||
// Chair of Algorithms and Data Structures. | ||
// Author: Johannes Kalmbach <[email protected]> | ||
|
||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <functional> | ||
#include <range/v3/all.hpp> | ||
#include <utility> | ||
|
||
// The following defines namespaces `ql::ranges` and `ql::views` that are almost | ||
// drop-in replacements for `std::ranges` and `std::views`. In C++20 mode (when | ||
// the `QLEVER_CPP_17` macro is not used), these namespaces are simply aliases | ||
// for `std::ranges` and `std::views`. In C++17 mode they contain the ranges and | ||
// views from Erice Niebler's `range-v3` library. NOTE: `ql::ranges::unique` | ||
// currently doesn't work, because the interface to this function is different | ||
// in both implementations. NOTE: There might be other caveats which we are | ||
// currently not aware of, because they only affect functions that we currently | ||
// don't use. For those, the following header can be expanded in the future. | ||
#ifndef QLEVER_CPP_17 | ||
#include <concepts> | ||
#include <ranges> | ||
#endif | ||
|
||
namespace ql { | ||
|
||
namespace ranges { | ||
#ifdef QLEVER_CPP_17 | ||
using namespace ::ranges; | ||
|
||
// The `view` concept (which is rather important when implementing custom views) | ||
// is in a different namespace in range-v3, so we make it manually accessible. | ||
template <typename T> | ||
CPP_concept view = ::ranges::cpp20::view<T>; | ||
#else | ||
using namespace std::ranges; | ||
#endif | ||
} // namespace ranges | ||
|
||
namespace views { | ||
#ifdef QLEVER_CPP_17 | ||
using namespace ::ranges::views; | ||
#else | ||
using namespace std::views; | ||
#endif | ||
} // namespace views | ||
|
||
// The namespace `ql::concepts` includes concepts that are contained in the | ||
// C++20 standard as well as in `range-v3`. | ||
namespace concepts { | ||
#ifdef QLEVER_CPP_17 | ||
using namespace ::concepts; | ||
#else | ||
using namespace std; | ||
#endif | ||
} // namespace concepts | ||
|
||
} // namespace ql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2024, University of Freiburg, | ||
// Chair of Algorithms and Data Structures. | ||
// Author: Johannes Kalmbach <[email protected]> | ||
|
||
#pragma once | ||
|
||
// Define the following macros: | ||
// `QL_OPT_CONCEPT(arg)` which expands to `arg` in C++20 mode, and to nothing in | ||
// C++17 mode. It can be used to easily opt out of concepts that are only used | ||
// for documentation and increased safety and not for overload resolution. | ||
// Example usage: | ||
// `(QL_OPT_CONCEPT(std::view) auto x = someFunction();` | ||
#ifdef QLEVER_CPP_17 | ||
#define QL_OPT_CONCEPT(arg) | ||
#else | ||
#define QL_OPT_CONCEPT(arg) arg | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.