1 //===----------------------------------------------------------------------===//
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-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef SUPPORT_UNWRAP_CONTAINER_ADAPTOR_H
10 #define SUPPORT_UNWRAP_CONTAINER_ADAPTOR_H
12 // Allows accessing the underlying container of the given adaptor.
13 template <class Adaptor
>
14 struct UnwrapAdaptor
: Adaptor
{
15 UnwrapAdaptor() = default;
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.
23 // TODO: make this work pre-C++20.
24 decltype(auto) get_comparator()
28 return (UnwrapAdaptor::comp
); // Put into parentheses to make sure the function returns a reference.
32 #endif // SUPPORT_UNWRAP_CONTAINER_ADAPTOR_H