Commit ab795217 authored by Stuart Berg's avatar Stuart Berg
Browse files

adjacency and blockmodel: On clang, replace std::max_element with...

adjacency and blockmodel: On clang, replace std::max_element with boost::first_max_element where necessary to avoid #576
parent 878fb5b6
......@@ -33,6 +33,10 @@
#include <boost/iterator/transform_iterator.hpp>
#include <boost/iterator/iterator_facade.hpp>
#ifdef __clang__
#include <boost/algorithm/minmax_element.hpp>
#endif
#include "transform_iterator.hh"
namespace boost
......@@ -449,9 +453,18 @@ public:
std::for_each(_edges.begin(), _edges.end(),
[](auto &es){es.second.shrink_to_fit();});
auto erange = boost::edges(*this);
auto iter = std::max_element(erange.first, erange.second,
[](const auto &a, const auto& b) -> bool
{return a.idx < b.idx;});
// Clang 8.0 fails to correctly recognize these as ForwardIterators,
// triggering a static_assert in std::max_element(). See #576.
#ifndef __clang__
auto iter = std::max_element(
#else
auto iter = boost::first_max_element(
#endif
erange.first, erange.second,
[](const auto &a, const auto& b) -> bool
{return a.idx < b.idx;});
if (iter == erange.second)
_edge_index_range = 0;
else
......
......@@ -22,6 +22,10 @@
#include <vector>
#ifdef __clang__
#include <boost/algorithm/minmax_element.hpp>
#endif
#include "../support/graph_state.hh"
#include "graph_blockmodel_util.hh"
......@@ -2356,10 +2360,18 @@ public:
E += _eweight[e];
size_t B = num_vertices(_bg);
auto vi = std::max_element(vertices(_g).first, vertices(_g).second,
[&](auto u, auto v)
{ return (this->_pclabel[u] <
this->_pclabel[v]); });
// Clang 8.0 fails to correctly recognize these as ForwardIterators,
// triggering a static_assert in std::max_element(). See #576.
#ifndef __clang__
auto vi = std::max_element(
#else
auto vi = boost::first_max_element(
#endif
vertices(_g).first, vertices(_g).second,
[&](auto u, auto v)
{ return (this->_pclabel[u] <
this->_pclabel[v]); });
size_t C = _pclabel[*vi] + 1;
vector<vector<size_t>> vcs(C);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment