Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove boost refs #108

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions adobe/placeable_concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define ADOBE_PLACEABLE_HPP

/************************************************************************************************/
#include <functional>

#include <boost/concept_check.hpp>

Expand Down
6 changes: 3 additions & 3 deletions source/adam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
/**************************************************************************************************/

using namespace std;
using namespace std::placeholders;
namespace ph = std::placeholders;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ugly. What is the ambiguity? Before accepting this change, I'd like to understand the issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick test - https://godbolt.org/z/Ydjff99Mo
Where does the ambiguity originate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message is as following, boost/bind.hpp is indirectly included through boost/signals2/signal.hpp.

/root/expr/adobe_source_libraries/source/adam.cpp: In member function ‘adobe::sheet_t::connection_t adobe::sheet_t::implementation_t::monitor_enabled(adobe::name_t, const adobe::name_t*, const adobe::name_t*, const monitor_enabled_t&)’:
/root/expr/adobe_source_libraries/source/adam.cpp:939:92: error: reference to ‘_1’ is ambiguous
  939 |                                                  touch_set, iter->cell_set_pos_m, monitor, _1, _2));
      |                                                                                            ^~
In file included from /root/expr/adobe_source_libraries/source/../adobe/adam.hpp:13,
                 from /root/expr/adobe_source_libraries/source/adam.cpp:8:
/usr/include/c++/9/functional:211:34: note: candidates are: ‘const std::_Placeholder<1> std::placeholders::_1’
  211 |     extern const _Placeholder<1> _1;
      |                                  ^~
In file included from /usr/include/boost/bind/bind.hpp:2356,
                 from /usr/include/boost/bind.hpp:22,
                 from /usr/include/boost/signals2/slot.hpp:15,
                 from /usr/include/boost/signals2/connection.hpp:24,
                 from /usr/include/boost/signals2/signal.hpp:22,
                 from /root/expr/adobe_source_libraries/source/../adobe/adam.hpp:16,
                 from /root/expr/adobe_source_libraries/source/adam.cpp:8:
/usr/include/boost/bind/placeholders.hpp:46:38: note:                 ‘constexpr const boost::arg<1> boost::placeholders::_1’
   46 | BOOST_STATIC_CONSTEXPR boost::arg<1> _1;


/**************************************************************************************************/

Expand Down Expand Up @@ -936,7 +936,7 @@ sheet_t::connection_t sheet_t::implementation_t::monitor_enabled(name_t n, const
(touch_set & priority_accessed_m).any()));

return monitor_enabled_m.connect(std::bind(&sheet_t::implementation_t::enabled_filter, this,
touch_set, iter->cell_set_pos_m, monitor, _1, _2));
touch_set, iter->cell_set_pos_m, monitor, ph::_1, ph::_2));
}

/**************************************************************************************************/
Expand Down Expand Up @@ -989,7 +989,7 @@ sheet_t::implementation_t::monitor_contributing(name_t n, const dictionary_t& ma

return iter->monitor_contributing_m.connect(
std::bind(monitor, std::bind(&sheet_t::implementation_t::contributing_set,
std::ref(*this), mark, _1)));
std::ref(*this), mark, ph::_1)));
}

/**************************************************************************************************/
Expand Down
8 changes: 4 additions & 4 deletions source/adam_evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**************************************************************************************************/

using namespace std::placeholders;
namespace ph = std::placeholders;

/**************************************************************************************************/

Expand Down Expand Up @@ -90,8 +90,8 @@ namespace adobe {
adam_callback_suite_t bind_to_sheet(sheet_t& sheet) {
adam_callback_suite_t suite;

suite.add_cell_proc_m = std::bind(&add_cell, std::ref(sheet), _1, _2, _3, _4);
suite.add_relation_proc_m = std::bind(&add_relation, std::ref(sheet), _1, _2, _3, _4);
suite.add_cell_proc_m = std::bind(&add_cell, std::ref(sheet), ph::_1, ph::_2, ph::_3, ph::_4);
suite.add_relation_proc_m = std::bind(&add_relation, std::ref(sheet), ph::_1, ph::_2, ph::_3, ph::_4);
suite.add_interface_proc_m = [&sheet](name_t name, bool linked, const line_position_t& position1,
const array_t& initializer, const line_position_t& position2,
const array_t& expression, const std::string& brief,
Expand All @@ -107,7 +107,7 @@ adam_callback_suite_t bind_to_sheet(sheet_t& sheet, external_model_t& external_m
adam_callback_suite_t suite = bind_to_sheet(sheet);

suite.add_external_proc_m =
std::bind(&adobe::external_model_t::add_cell, std::ref(external_model), _1);
std::bind(&adobe::external_model_t::add_cell, std::ref(external_model), ph::_1);

return suite;
}
Expand Down
8 changes: 4 additions & 4 deletions source/adam_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**************************************************************************************************/

using namespace std;
using namespace std::placeholders;
namespace ph = std::placeholders;

/**************************************************************************************************/

Expand Down Expand Up @@ -84,15 +84,15 @@ namespace adobe {

adam_parser::adam_parser(std::istream& in, const line_position_t& position)
: expression_parser(in, position) {
set_keyword_extension_lookup(std::bind(&keyword_lookup, _1));
set_keyword_extension_lookup(std::bind(&keyword_lookup, ph::_1));
}

/**************************************************************************************************/

adam_parser::adam_parser(std::istream& in, const line_position_t& position,
const adam_callback_suite_t& callbacks)
: expression_parser(in, position), adam_callback_suite_m(callbacks) {
set_keyword_extension_lookup(std::bind(&keyword_lookup, _1));
set_keyword_extension_lookup(std::bind(&keyword_lookup, ph::_1));

assert(adam_callback_suite_m.add_cell_proc_m); // all callbacks are required.
assert(adam_callback_suite_m.add_relation_proc_m);
Expand All @@ -112,7 +112,7 @@ array_t parse_adam_expression(const std::string& str_expression) {
std::stringstream expression_stream(str_expression);

adobe::expression_parser parser(expression_stream, line_position_t("expression"));
parser.set_keyword_extension_lookup(std::bind(&keyword_lookup, _1));
parser.set_keyword_extension_lookup(std::bind(&keyword_lookup, ph::_1));

adobe::array_t expression;
parser.require_expression(expression);
Expand Down
8 changes: 4 additions & 4 deletions source/eve_evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**************************************************************************************************/

using namespace std;
using namespace std::placeholders;
namespace ph = std::placeholders;

/**************************************************************************************************/

Expand Down Expand Up @@ -199,9 +199,9 @@ eve_callback_suite_t bind_layout(const bind_layout_proc_t& proc, sheet_t& sheet,
eve_callback_suite_t suite;

suite.add_view_proc_m = std::bind(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider bind -> lambda?

proc, _1, _3, std::bind(&evaluate_named_arguments, std::ref(evaluator), _4));
suite.add_cell_proc_m = std::bind(&add_cell, std::ref(sheet), _1, _2, _3, _4);
suite.add_relation_proc_m = std::bind(&add_relation, std::ref(sheet), _1, _2, _3, _4);
proc, ph::_1, ph::_3, std::bind(&evaluate_named_arguments, std::ref(evaluator), ph::_4));
suite.add_cell_proc_m = std::bind(&add_cell, std::ref(sheet), ph::_1, ph::_2, ph::_3, ph::_4);
suite.add_relation_proc_m = std::bind(&add_relation, std::ref(sheet), ph::_1, ph::_2, ph::_3, ph::_4);
suite.add_interface_proc_m = [&sheet](name_t name, bool linked, const line_position_t& position1,
const array_t& initializer, const line_position_t& position2,
const array_t& expression, const std::string& brief,
Expand Down
4 changes: 2 additions & 2 deletions test/adam_smoke/adam_smoke_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

/**************************************************************************************************/

using namespace std::placeholders;
namespace ph = std::placeholders;

/**************************************************************************************************/

Expand Down Expand Up @@ -162,7 +162,7 @@ bool test_sheet(const fs::path& root) {

// Connect the virtual machine to the sheet.

sheet.machine_m.set_variable_lookup(std::bind(&adobe::sheet_t::get, &sheet, _1));
sheet.machine_m.set_variable_lookup(std::bind(&adobe::sheet_t::get, &sheet, ph::_1));

read_sheet(sheet_path, sheet);

Expand Down
10 changes: 5 additions & 5 deletions test/adam_tutorial/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**************************************************************************************************/

namespace fs = std::filesystem;
using namespace std::placeholders;
namespace ph = std::placeholders;

/**************************************************************************************************/

Expand Down Expand Up @@ -86,16 +86,16 @@ struct sheet_tracker {
sheet_tracker(const fs::path& sheet_path, const fs::path& input_path)
: callbacks_m(adobe::bind_to_sheet(sheet_m)) {
// attach the VM to the sheet.
sheet_m.machine_m.set_variable_lookup(std::bind(&adobe::sheet_t::get, &sheet_m, _1));
sheet_m.machine_m.set_variable_lookup(std::bind(&adobe::sheet_t::get, &sheet_m, ph::_1));

const auto& sheet_path_str{sheet_path.native()};
std::ifstream sheet_stream{sheet_path_str.c_str()};

callbacks_m.add_cell_proc_m = std::bind(&sheet_tracker::add_cell_trap, std::ref(*this),
callbacks_m.add_cell_proc_m, _1, _2, _3, _4);
callbacks_m.add_cell_proc_m, ph::_1, ph::_2, ph::_3, ph::_4);
callbacks_m.add_interface_proc_m =
std::bind(&sheet_tracker::add_interface_trap, std::ref(*this),
callbacks_m.add_interface_proc_m, _1, _2, _3, _4, _5, _6);
callbacks_m.add_interface_proc_m, ph::_1, ph::_2, ph::_3, ph::_4, ph::_5, ph::_6);

if (!sheet_stream.is_open()) {
std::cerr << "Could not open \"";
Expand Down Expand Up @@ -210,7 +210,7 @@ void sheet_tracker::loop() {
sheet_m.update();
for (cell_set_t::iterator iter = cell_set_m.begin(), end = cell_set_m.end(); iter != end;
++iter) {
sheet_m.monitor_value(iter->first, std::bind(&simple_display, std::ref(*iter), _1));
sheet_m.monitor_value(iter->first, std::bind(&simple_display, std::ref(*iter), ph::_1));
}

while (true) {
Expand Down
4 changes: 2 additions & 2 deletions test/eve_smoke/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/**************************************************************************************************/

using namespace std::placeholders;
namespace ph = std::placeholders;

/**************************************************************************************************/

Expand Down Expand Up @@ -91,7 +91,7 @@ void testParse(std::filesystem::path& fileName) {
adobe::parse(
stream, adobe::line_position_t(path.c_str()),
adobe::eve_callback_suite_t::position_t(),
adobe::bind_layout(std::bind(&assemble, _2, _3), layout_sheet, layout_sheet.machine_m));
adobe::bind_layout(std::bind(&assemble, ph::_2, ph::_3), layout_sheet, layout_sheet.machine_m));
}

/**************************************************************************************************/
Expand Down
28 changes: 17 additions & 11 deletions test/property_model_eval/queryable_sheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**************************************************************************************************/

using namespace std::placeholders;
namespace ph = std::placeholders;

/**************************************************************************************************/

Expand All @@ -21,7 +21,7 @@ namespace adobe {

queryable_sheet_t::queryable_sheet_t(adam_parser& p) : no_pure_outputs_m(true), parser_m(p) {
// attach the VM to the sheet.
sheet_m.machine_m.set_variable_lookup(std::bind(&adobe::sheet_t::get, &sheet_m, _1));
sheet_m.machine_m.set_variable_lookup(std::bind(&adobe::sheet_t::get, &sheet_m, ph::_1));

parser_m.adam_callback_suite_m = setup_callbacks();
(void)parser_m.is_sheet_specifier(sheet_name_m);
Expand All @@ -43,35 +43,41 @@ void queryable_sheet_t::begin_monitoring() {
std::size_t i(iter->second);
name_t& name(name_m[i]);
sheet_m.monitor_enabled(name, NULL, NULL,
std::bind(adobe::assign(), _1, std::ref(active_m[i])));
std::bind(adobe::assign(), ph::_1, std::ref(active_m[i])));

std::vector<name_t> v;
v.push_back(name);
sheet_m.monitor_enabled(
dummy, &v[0], 1 + &v[0],
std::bind(adobe::assign(), _1, std::ref(priority_accessed_m[i])));
std::bind(adobe::assign(), ph::_1, std::ref(priority_accessed_m[i])));

sheet_m.monitor_value(name, std::bind(adobe::assign(), _1, std::ref(value_m[i])));
sheet_m.monitor_value(name, [&value_m_at_index_i = value_m[i]](any_regular_t val) {
adobe::assign{}(val, value_m_at_index_i);
});

sheet_m.monitor_contributing(
name, dictionary_t(), std::bind(adobe::assign(), _1, std::ref(contributors_m[i])));
name, dictionary_t(), std::bind(adobe::assign(), ph::_1, std::ref(contributors_m[i])));
}

for (queryable_sheet_t::index_t::iterator iter = output_index_m.begin(),
e = output_index_m.end();
iter != e; ++iter) {
std::size_t i(iter->second);
sheet_m.monitor_value(name_m[i], std::bind(adobe::assign(), _1, std::ref(value_m[i])));
sheet_m.monitor_value(name_m[i], [&value_m_at_index_i = value_m[i]](any_regular_t val) {
Copy link
Contributor Author

@g-217 g-217 Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With clang-14/16, std::bind is not working with type any_regular_t for adobe::assign.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an understanding of why? Maybe it would be better to fix the underlying cause.

adobe::assign{}(val, value_m_at_index_i);
});

sheet_m.monitor_contributing(
name_m[i], dictionary_t(),
std::bind(adobe::assign(), _1, std::ref(contributors_m[i])));
std::bind(adobe::assign(), ph::_1, std::ref(contributors_m[i])));
}
for (queryable_sheet_t::index_t::iterator iter = invariant_index_m.begin(),
e = invariant_index_m.end();
iter != e; ++iter) {
std::size_t i(iter->second);
sheet_m.monitor_value(name_m[i], std::bind(adobe::assign(), _1, std::ref(value_m[i])));
sheet_m.monitor_value(name_m[i], [&value_m_at_index_i = value_m[i]](any_regular_t val) {
adobe::assign{}(val, value_m_at_index_i);
});
}
}

Expand Down Expand Up @@ -113,10 +119,10 @@ any_regular_t queryable_sheet_t::inspect(const array_t& expression) {
adam_callback_suite_t queryable_sheet_t::setup_callbacks() {
adam_callback_suite_t callbacks(adobe::bind_to_sheet(sheet_m));
callbacks.add_cell_proc_m = std::bind(&queryable_sheet_t::add_cell_trap, this,
callbacks.add_cell_proc_m, _1, _2, _3, _4);
callbacks.add_cell_proc_m, ph::_1, ph::_2, ph::_3, ph::_4);
callbacks.add_interface_proc_m =
std::bind(&queryable_sheet_t::add_interface_trap, this, callbacks.add_interface_proc_m,
_1, _2, _3, _4, _5, _6);
ph::_1, ph::_2, ph::_3, ph::_4, ph::_5, ph::_6);
return callbacks;
}

Expand Down
Loading