Skip to content

Commit 5947bd0

Browse files
committed
Use std::less<> for Labels to enable heterogeneous lookup on C++14+
1 parent 0a779ab commit 5947bd0

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

core/include/prometheus/labels.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
#pragma once
22

3+
#if defined(__cpp_lib_generic_associative_lookup)
4+
#include <functional>
5+
#endif
36
#include <map>
47
#include <string>
58

69
namespace prometheus {
710

811
/// \brief Multiple labels and their value.
12+
///
13+
/// Uses the transparent comparator std::less<> on C++14 and newer to allow
14+
/// heterogeneous lookup, falling back to the default comparator on C++11.
15+
#if defined(__cpp_lib_generic_associative_lookup)
16+
using Labels = std::map<std::string, std::string, std::less<>>;
17+
#else
918
using Labels = std::map<std::string, std::string>;
19+
#endif
1020

1121
/// \brief Single label and its value.
1222
using Label = Labels::value_type;

0 commit comments

Comments
 (0)