Skip to content

Commit d5531e2

Browse files
Merge pull request #418 from gogagum/feature/remove-boost-bind-usages
Remove Boost.Bind usages, replace with lambda
2 parents 167ac18 + 2d182cf commit d5531e2

File tree

5 files changed

+16
-28
lines changed

5 files changed

+16
-28
lines changed

CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ target_link_libraries(boost_graph
2222
Boost::array
2323
Boost::assert
2424
Boost::bimap
25-
Boost::bind
2625
Boost::concept_check
2726
Boost::config
2827
Boost::container_hash

include/boost/graph/howard_cycle_ratio.hpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <functional>
1414
#include <limits>
1515

16-
#include <boost/bind/bind.hpp>
1716
#include <boost/tuple/tuple.hpp>
1817
#include <boost/type_traits/is_same.hpp>
1918
#include <boost/type_traits/remove_const.hpp>
@@ -241,14 +240,10 @@ namespace detail
241240
typename graph_traits< Graph >::out_edge_iterator oei, oeie;
242241
for (boost::tie(vi, vie) = vertices(m_g); vi != vie; ++vi)
243242
{
244-
using namespace boost::placeholders;
245-
246243
boost::tie(oei, oeie) = out_edges(*vi, m_g);
247-
typename graph_traits< Graph >::out_edge_iterator mei
248-
= boost::first_max_element(oei, oeie,
249-
boost::bind(m_cmp,
250-
boost::bind(&EdgeWeight1::operator[], m_ew1m, _1),
251-
boost::bind(&EdgeWeight1::operator[], m_ew1m, _2)));
244+
auto mei = boost::first_max_element(oei, oeie,
245+
[this](const auto& first, const auto& second)
246+
{ return m_cmp(m_ew1m[first], m_ew1m[second]); });
252247
if (mei == oeie)
253248
{
254249
if (m_sink == graph_traits< Graph >().null_vertex())
@@ -356,16 +351,17 @@ namespace detail
356351
*/
357352
float_t policy_mcr()
358353
{
359-
using namespace boost::placeholders;
360-
361354
std::fill(m_col_bfs.begin(), m_col_bfs.end(), my_white);
362355
color_map_t vcm_ = color_map_t(m_col_bfs.begin(), m_vim);
363356
typename graph_traits< Graph >::vertex_iterator uv_itr, vie;
364357
boost::tie(uv_itr, vie) = vertices(m_g);
365358
float_t mcr = m_bound;
366359
while ((uv_itr = std::find_if(uv_itr, vie,
367-
boost::bind(std::equal_to< my_color_type >(), my_white,
368-
boost::bind(&color_map_t::operator[], vcm_, _1))))
360+
[this, &vcm_](const auto& uv)
361+
{
362+
return std::equal_to< my_color_type >()(
363+
my_white, vcm_[uv]);
364+
}))
369365
!= vie)
370366
/// While there are undiscovered vertices
371367
{

include/boost/graph/king_ordering.hpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <vector>
1616
#include <algorithm>
1717
#include <boost/config.hpp>
18-
#include <boost/bind/bind.hpp>
1918
#include <boost/tuple/tuple.hpp>
2019
#include <boost/graph/detail/sparse_ordering.hpp>
2120
#include <boost/graph/graph_utility.hpp>
@@ -49,8 +48,6 @@ namespace detail
4948
template < typename Vertex, typename Graph >
5049
void finish_vertex(Vertex, Graph& g)
5150
{
52-
using namespace boost::placeholders;
53-
5451
typename graph_traits< Graph >::out_edge_iterator ei, ei_end;
5552
Vertex v, w;
5653

@@ -61,7 +58,7 @@ namespace detail
6158
reverse_iterator rbegin = Qptr->rbegin();
6259

6360
// heap the vertices already there
64-
std::make_heap(rbegin, rend, boost::bind< bool >(comp, _2, _1));
61+
std::make_heap(rbegin, rend, [this](const auto& first, const auto& second) { return comp(second, first); });
6562

6663
unsigned i = 0;
6764

include/boost/graph/transitive_closure.hpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212
#include <vector>
1313
#include <algorithm> // for std::min and std::max
14-
#include <functional>
14+
#include <functional> //for std::less
1515
#include <boost/config.hpp>
16-
#include <boost/bind/bind.hpp>
1716
#include <boost/graph/strong_components.hpp>
1817
#include <boost/graph/topological_sort.hpp>
1918
#include <boost/graph/graph_concepts.hpp>
@@ -130,16 +129,16 @@ void transitive_closure(const Graph& g, GraphTC& tc,
130129
std::vector< std::vector< cg_vertex > > CG_vec(num_vertices(CG));
131130
for (size_type i = 0; i < num_vertices(CG); ++i)
132131
{
133-
using namespace boost::placeholders;
134-
135132
typedef typename boost::graph_traits< CG_t >::adjacency_iterator
136133
cg_adj_iter;
137134
std::pair< cg_adj_iter, cg_adj_iter > pr = adjacent_vertices(i, CG);
138135
CG_vec[i].assign(pr.first, pr.second);
139136
std::sort(CG_vec[i].begin(), CG_vec[i].end(),
140-
boost::bind(std::less< cg_vertex >(),
141-
boost::bind(detail::subscript(topo_number), _1),
142-
boost::bind(detail::subscript(topo_number), _2)));
137+
[&topo_number](const auto& cg_0, const auto& cg_1)
138+
{
139+
return std::less< cg_vertex >()(
140+
topo_number[cg_0], topo_number[cg_1]);
141+
});
143142
}
144143

145144
std::vector< std::vector< cg_vertex > > chains;

test/graph.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,8 @@ bool check_vertex_cleared(Graph& g, Vertex v, ID id)
7070
found = ai;
7171
break;
7272
}
73-
#elif defined(BOOST_NO_CXX98_BINDERS)
74-
found
75-
= std::find_if(ai, aiend, std::bind(cmp, v, std::placeholders::_1));
7673
#else
77-
found = std::find_if(ai, aiend, std::bind1st(cmp, v));
74+
found = std::find_if(ai, aiend, [&v, &cmp](const auto& el) { return cmp(v, el); });
7875
#endif
7976

8077
if (found != aiend)

0 commit comments

Comments
 (0)