Is it possible to use bundled properties in the Boost Graph Library, with a standard library type, while also using that type's overload of the <<
stream operator to satisfy write_graphviz
?
#include <boost/graph/graphviz.hpp>
namespace boost {
namespace detail {
namespace has_left_shift_impl {
template <typename T>
inline std::ostream &operator<<(std::ostream &o, const std::array<T,2> &a) {
o << a[0] << ',' << a[1];
return o;
}
}
}
}
static_assert(boost::has_left_shift<
std::basic_ostream<char>,
std::array<double,2>
>::value,"");
int main()
{
using namespace boost;
typedef adjacency_list<vecS, vecS, directedS, no_property, std::array<double,2>> Graph;
Graph g;
add_edge(0, 1, {123,456}, g);
write_graphviz(std::cout, g, default_writer(),
make_label_writer(boost::get(edge_bundle,g)));
return 0;
}
Faced with a Boost static assert, I modified my code to that above; adopting a suggestion from here, wherein the <<
implementation is defined within the boost::detail::has_left_shift_impl
namespace. Alas, I'm now faced with another error:
/usr/include/boost/lexical_cast.hpp:1624:50: error: cannot bind ‘std::basic_ostream<char>’ lvalue to ‘std::basic_ostream<char>&&’
bool const result = !(out_stream << input).fail();
Is there a way to provide an overload of <<
which can be used by write_graphviz
? I'm using Ubuntu 14.10 and GCC 4.9.1.