Skip to content

Commit 5e5c46c

Browse files
committed
Fix identity functors
In order to accept both lvalue and rvalue arguments, their argument must be deduced, not a class template argument (and therefore concretely specified).
1 parent 08df8dc commit 5e5c46c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/goto-programs/cfg.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ template <class T>
3838
class cfg_instruction_to_dense_integert
3939
{
4040
public:
41-
std::size_t operator()(T &&t) const
41+
template <class U>
42+
std::size_t operator()(U &&u) const
4243
{
43-
return std::forward<T>(identity_functort<T>{}(t));
44+
return std::forward<U>(identity_functort{}(u));
4445
}
4546
};
4647

src/util/dense_integer_map.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ Author: Diffblue Ltd
1919
#include <util/invariant.h>
2020

2121
/// Identity functor. When we use C++20 this can be replaced with std::identity.
22-
template <typename T>
2322
class identity_functort
2423
{
2524
public:
26-
constexpr T &&operator()(T &&t) const
25+
template <typename T>
26+
constexpr auto operator()(T &&t) const -> decltype(std::forward<T>(t))
2727
{
2828
return std::forward<T>(t);
2929
}
@@ -40,7 +40,7 @@ class identity_functort
4040
/// cfg_basic_blockst. Due to the vector storage the precise interface of
4141
/// std::map is hard to achieve, but something close is practically achievable
4242
/// for the interested developer.
43-
template <class K, class V, class KeyToDenseInteger = identity_functort<K>>
43+
template <class K, class V, class KeyToDenseInteger = identity_functort>
4444
class dense_integer_mapt
4545
{
4646
public:

0 commit comments

Comments
 (0)