aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/stllike/select.h
blob: ca2527197f42a8d57a5edd646a9a4ce009960f64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

namespace vespalib {

// Convenience functor for extracting the first element of a std::pair (or compatible type)
template <typename Pair>
struct Select1st {
    constexpr typename Pair::first_type& operator()(Pair& p) const noexcept {
        return p.first;
    }
    constexpr const typename Pair::first_type& operator()(const Pair& p) const noexcept {
        return p.first;
    }
};

}