Skip to content

Commit a905ac0

Browse files
committed
Replace lambda by member function reference to silence Visual Studio
Visual Studio previously warned about a reference to a local or temporary being returned. This seems spurious, possibly caused by "this" being passed by-value to the lambda and Visual Studio thus assuming a copy was being created. Going via a reference to a member function makes Visual Studio happy (and should not change the behaviour in any way).
1 parent 5e5e264 commit a905ac0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/pointer-analysis/value_set_analysis.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Author: Daniel Kroening, [email protected]
1919
#include <langapi/language_util.h>
2020

2121
void value_sets_to_xml(
22-
std::function<const value_sett &(goto_programt::const_targett)> get_value_set,
22+
const std::function<const value_sett &(goto_programt::const_targett)>
23+
&get_value_set,
2324
const goto_programt &goto_program,
2425
xmlt &dest)
2526
{

src/pointer-analysis/value_set_analysis.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ Author: Daniel Kroening, [email protected]
2121
class xmlt;
2222

2323
void value_sets_to_xml(
24-
std::function<const value_sett &(goto_programt::const_targett)> get_value_set,
24+
const std::function<const value_sett &(goto_programt::const_targett)>
25+
&get_value_set,
2526
const goto_programt &goto_program,
2627
xmlt &dest);
2728

@@ -39,12 +40,18 @@ class value_set_analysis_templatet:
3940
{
4041
}
4142

43+
const value_sett &get_value_set(goto_programt::const_targett t)
44+
{
45+
return (*this)[t].value_set;
46+
}
47+
4248
void convert(
4349
const goto_programt &goto_program,
4450
xmlt &dest) const
4551
{
52+
using std::placeholders::_1;
4653
value_sets_to_xml(
47-
[this](locationt l) { return (*this)[l].value_set; },
54+
std::bind(&value_set_analysis_templatet::get_value_set, *this, _1),
4855
goto_program,
4956
dest);
5057
}

0 commit comments

Comments
 (0)