Skip to content

Commit

Permalink
Fix the compilation and do some cleaning up.
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Kalmbach <[email protected]>
  • Loading branch information
joka921 committed Dec 17, 2024
1 parent 87dea4e commit 01113d3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion benchmark/JoinAlgorithmBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ class GeneralInterfaceImplementation : public BenchmarkInterface {
bool addNewRowToBenchmarkTable(
ResultTable* table,
const QL_OPT_CONCEPT(
(ad_utility::SameAsAny<float, size_t>)) auto changingParameterValue,
ad_utility::SameAsAny<float, size_t>) auto changingParameterValue,
ad_utility::InvocableWithExactReturnType<bool, float, size_t, size_t,
size_t, size_t, float,
float> auto stopFunction,
Expand Down
2 changes: 1 addition & 1 deletion benchmark/infrastructure/Benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class BenchmarkResults {
that the new `CopyableUniquePtr` will own.
*/
template <QL_CONCEPT_OR_TYPENAME(
(ad_utility::SameAsAny<ResultTable, ResultEntry, ResultGroup>)) EntryType>
ad_utility::SameAsAny<ResultTable, ResultEntry, ResultGroup>) EntryType>
static EntryType& addEntryToContainerVector(
PointerVector<EntryType>& targetVector, auto&&... constructorArgs) {
targetVector.push_back(ad_utility::make_copyable_unique<EntryType>(
Expand Down
18 changes: 13 additions & 5 deletions src/backports/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@
// `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:
// Example usages:
// `(QL_OPT_CONCEPT(std::view) auto x = someFunction();`
// `void f(QL_OPT_CONCEPT(std::view) auto x) {...}`
//
// `QL_CONCEPT_OR_TYPENAME(arg)` which expands to `arg` in C++20 mode, and to
// `typename` in C++17 mode. Example: `template
// <QL_CONCEPT_OR_TYPENAME(ql::same_as<int>) T> void f(){...}`
//
// Note: The macros are variadic to allow for commas in the argument (e.g.
// `QL_OPT_CONCEPT(SameAsAny<int, float>)`.
#ifdef QLEVER_CPP_17
#define QL_OPT_CONCEPT(arg)
#define QL_CONCEPT_OR_TYPENAME(arg) typename
#define QL_OPT_CONCEPT(...)
#define QL_CONCEPT_OR_TYPENAME(...) typename
#else
#define QL_OPT_CONCEPT(arg) arg
#define QL_CONCEPT_OR_TYPENAME(arg) arg
#define QL_OPT_CONCEPT(...) __VA_ARGS__
#define QL_CONCEPT_OR_TYPENAME(...) __VA_ARGS__
#endif

// The namespace `ql::concepts` includes concepts that are contained in the
Expand Down
4 changes: 2 additions & 2 deletions src/util/ConfigManager/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ requires std::is_object_v<HashMapType> auto ConfigManager::allHashMapEntries(
}

// ____________________________________________________________________________
template <QL_CONCEPT_OR_TYPENAME(
(SameAsAny<ConfigOption&, const ConfigOption&>)) ReturnReference>
template <QL_CONCEPT_OR_TYPENAME(SameAsAny<ConfigOption&, const ConfigOption&>)
ReturnReference>
std::vector<std::pair<std::string, ReturnReference>>
ConfigManager::configurationOptionsImpl(
SimilarTo<ad_utility::HashMap<std::string, HashMapEntry>> auto&
Expand Down
3 changes: 2 additions & 1 deletion src/util/ConfigManager/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,8 @@ class ConfigManager {
@tparam ReturnReference Should be either `ConfigOption&`, or `const
ConfigOption&`.
*/
template <typename ReturnReference>
template <QL_CONCEPT_OR_TYPENAME(
SameAsAny<ConfigOption&, const ConfigOption&>) ReturnReference>
static std::vector<std::pair<std::string, ReturnReference>>
configurationOptionsImpl(
SimilarTo<ad_utility::HashMap<std::string, HashMapEntry>> auto&
Expand Down
6 changes: 2 additions & 4 deletions src/util/Iterators.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Chair of Algorithms and Data Structures.
// Author: Johannes Kalmbach <[email protected]>

#ifndef QLEVER_ITERATORS_H
#define QLEVER_ITERATORS_H
#pragma once

#include <cstdint>
#include <iterator>
#include <type_traits>

#include "backports/algorithm.h"
#include "util/Enums.h"
#include "util/TypeTraits.h"

Expand Down Expand Up @@ -399,5 +399,3 @@ class InputRangeTypeErased {
using iterator = typename InputRangeFromGet<ValueType>::Iterator;
};
} // namespace ad_utility

#endif // QLEVER_ITERATORS_H
10 changes: 3 additions & 7 deletions src/util/JoinAlgorithms/JoinAlgorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <ranges>

#include "backports/algorithm.h"
#include "backports/concepts.h"
#include "engine/idTable/IdTable.h"
#include "global/Id.h"
#include "util/Generator.h"
Expand Down Expand Up @@ -762,13 +763,8 @@ struct BlockZipperJoinImpl {
#if defined(Side) || defined(Blocks)
#error Side or Blocks are already defined
#endif
#ifdef QLEVER_CPP_17
#define Side auto
#define Blocks auto
#else
#define Side SameAsAny<LeftSide, RightSide> auto
#define Blocks SameAsAny<LeftBlocks, RightBlocks> auto
#endif
#define Side QL_OPT_CONCEPT(SameAsAny<LeftSide, RightSide>) auto
#define Blocks QL_OPT_CONCEPT(SameAsAny<LeftBlocks, RightBlocks>) auto

// Type alias for the result of the projection. Elements from the left and
// right input must be projected to the same type.
Expand Down

0 comments on commit 01113d3

Please sign in to comment.