brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 19f7943 Raw
33 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef SUPPORT_UNWRAP_CONTAINER_ADAPTOR_H10#define SUPPORT_UNWRAP_CONTAINER_ADAPTOR_H11 12// Allows accessing the underlying container of the given adaptor.13template <class Adaptor>14struct UnwrapAdaptor : Adaptor {15  UnwrapAdaptor() = default;16 17  UnwrapAdaptor(Adaptor&& adaptor) : Adaptor(std::move(adaptor)) {}18  // `c` is a protected member variable of the base class.19  decltype(auto) get_container() {20    return (UnwrapAdaptor::c); // Put into parentheses to make sure the function returns a reference.21  }22 23  // TODO: make this work pre-C++20.24  decltype(auto) get_comparator()25  requires requires {26    UnwrapAdaptor::c;27  } {28    return (UnwrapAdaptor::comp); // Put into parentheses to make sure the function returns a reference.29  }30};31 32#endif // SUPPORT_UNWRAP_CONTAINER_ADAPTOR_H33