Skip to content

Commit

Permalink
Revert "Use the stdlib's ref and cref function templates."
Browse files Browse the repository at this point in the history
This reverts commit a237a31.

Rationale:

With `std::ref` instead of `boost::ref`, luabind related code fails at
runtime (I love the smell of dynamic languages burning to the ground).

This happens, because luabind hardcodes a reference wrapper predicate
via SFINA for `boost::reference_wrapper` (the type returned from
`boost::ref`), but fails do to so for stdlib facilities (`std::ref`
and `std::reference_wrapper`).

I don't even blame them, I would have done the same in the year 2010,
as the upsream package is basically unmaintained since freaking 5 years.

References:

- https://gist.github.com/daniel-j-h/c98c03b3d02f713d035e
- #1646
- https://github.com/luabind/luabind/blob/457f28ab5a0d6331409883348588b43e3a0bc944/luabind/detail/convert_to_lua.hpp#L4MC�$
  • Loading branch information
daniel-j-h committed Sep 7, 2015
1 parent c031d62 commit 5f14071
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions extractor/extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <atomic>
#include <chrono>
#include <fstream>
#include <functional>
#include <iostream>
#include <thread>
#include <unordered_map>
Expand Down Expand Up @@ -179,17 +178,17 @@ int extractor::run()
++number_of_nodes;
luabind::call_function<void>(
local_state, "node_function",
std::cref(static_cast<const osmium::Node &>(*entity)),
std::ref(result_node));
boost::cref(static_cast<const osmium::Node &>(*entity)),
boost::ref(result_node));
resulting_nodes.push_back(std::make_pair(x, result_node));
break;
case osmium::item_type::way:
result_way.clear();
++number_of_ways;
luabind::call_function<void>(
local_state, "way_function",
std::cref(static_cast<const osmium::Way &>(*entity)),
std::ref(result_way));
boost::cref(static_cast<const osmium::Way &>(*entity)),
boost::ref(result_way));
resulting_ways.push_back(std::make_pair(x, result_way));
break;
case osmium::item_type::relation:
Expand Down
5 changes: 3 additions & 2 deletions extractor/restriction_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../util/osrm_exception.hpp"
#include "../util/simple_logger.hpp"

#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/regex.hpp>
#include <boost/ref.hpp>
#include <boost/regex.hpp>

#include <algorithm>
#include <functional>

namespace
{
Expand Down Expand Up @@ -86,7 +87,7 @@ void RestrictionParser::ReadRestrictionExceptions(lua_State *lua_state)
luabind::set_pcall_callback(&lua_error_callback);
// get list of turn restriction exceptions
luabind::call_function<void>(lua_state, "get_exceptions",
std::ref(restriction_exceptions));
boost::ref(restriction_exceptions));
const unsigned exception_count = restriction_exceptions.size();
SimpleLogger().Write() << "Found " << exception_count
<< " exceptions to turn restrictions:";
Expand Down

0 comments on commit 5f14071

Please sign in to comment.