Unable to use integer edge weights with Kamada-Kawai layout - c++

The question started here, but after all the updates it is already a different question with a different title.
My Graph type is defined as follows:
using Graph = boost::adjacency_list<vecS, setS, undirectedS, State, CostType>;
where CostType happens to be int.
I am trying to obtain the Kamada-Kawai spring layout as follows:
template <class PointMap>
PointMap layout() const {
PointMap res;
boost::associative_property_map<PointMap> temp(res);
circle_graph_layout(g_, temp, 10.0);
// https://stackoverflow.com/q/33903879/2725810
// https://stackoverflow.com/a/8555715/2725810
typedef std::map<VertexDescriptor, std::size_t> IndexMap;
IndexMap mapIndex;
associative_property_map<IndexMap> propmapIndex(mapIndex);
// http://www.boost.org/doc/libs/1_59_0/libs/graph/doc/bundles.html
kamada_kawai_spring_layout(g_, temp, get(edge_bundle, g_),
square_topology<>(50.0), side_length(50.0),
layout_tolerance<CostType>(),
CostType(1), propmapIndex);
return res;
}
gcc version 4.8.2 complains:
In file included from Graph.h:13:0,
from Astar.h:5,
from Test.cpp:4:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp: In instantiation of ‘bool boost::detail::graph::kamada_kawai_spring_layout_impl<Topology, Graph, PositionMap, WeightMap, EdgeOrSideLength, Done, VertexIndexMap, DistanceMatrix, SpringStrengthMatrix, PartialDerivativeMap>::run() [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>; EdgeOrSideLength = boost::detail::graph::edge_or_side<false, double>; Done = boost::layout_tolerance<int>; VertexIndexMap = boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >; DistanceMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; SpringStrengthMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; PartialDerivativeMap = boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&>]’:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:524:20: required from ‘bool boost::kamada_kawai_spring_layout(const Graph&, PositionMap, WeightMap, const Topology&, boost::detail::graph::edge_or_side<EdgeOrSideLength, T>, Done, typename boost::property_traits<DistanceMap>::value_type, VertexIndexMap, DistanceMatrix, SpringStrengthMatrix, PartialDerivativeMap) [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>; T = double; bool EdgeOrSideLength = false; Done = boost::layout_tolerance<int>; VertexIndexMap = boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >; DistanceMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; SpringStrengthMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; PartialDerivativeMap = boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&>; typename boost::property_traits<DistanceMap>::value_type = int]’
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:559:79: required from ‘bool boost::kamada_kawai_spring_layout(const Graph&, PositionMap, WeightMap, const Topology&, boost::detail::graph::edge_or_side<EdgeOrSideLength, T>, Done, typename boost::property_traits<DistanceMap>::value_type, VertexIndexMap) [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>; T = double; bool EdgeOrSideLength = false; Done = boost::layout_tolerance<int>; VertexIndexMap = boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >; typename boost::property_traits<DistanceMap>::value_type = int]’
Graph.h:112:61: required from ‘PointMap StateGraph<StateNeighbor>::layout() const [with PointMap = std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > >; StateNeighbor = StateNeighbor<Pancake>]’
Drawer.h:60:75: required from ‘Drawer<Graph>::Drawer(const Graph&) [with Graph = StateGraph<StateNeighbor<Pancake> >]’
Test.cpp:34:22: required from here
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:313:96: error: no matching function for call to ‘boost::detail::graph::linear_solver<2ul>::solve(boost::detail::graph::kamada_kawai_spring_layout_impl<boost::square_topology<>, boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>, boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >, boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>, boost::detail::graph::edge_or_side<false, double>, boost::layout_tolerance<int>, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&> >::weight_type [2][2], boost::detail::graph::kamada_kawai_spring_layout_impl<boost::square_topology<>, boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>, boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >, boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>, boost::detail::graph::edge_or_side<false, double>, boost::layout_tolerance<int>, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&> >::deriv_type&)’
_difference_type delta = -linear_solver<Point::dimensions>::solve(dE_d_d, dE_d);
^
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:313:96: note: candidate is:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:95:18: note: template<class Vec> static Vec boost::detail::graph::linear_solver<2ul>::solve(double (*)[2], Vec)
static Vec solve(double mat[2][2], Vec rhs) {
^
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:95:18: note: template argument deduction/substitution failed:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:313:96: note: cannot convert ‘dE_d_d’ (type ‘boost::detail::graph::kamada_kawai_spring_layout_impl<boost::square_topology<>, boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>, boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >, boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>, boost::detail::graph::edge_or_side<false, double>, boost::layout_tolerance<int>, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&> >::weight_type [2][2] {aka int [2][2]}’) to type ‘double (*)[2]’
_difference_type delta = -linear_solver<Point::dimensions>::solve(dE_d_d, dE_d);
This message is too cryptic for me to understand. It has something to do with not being able to convert int [2][2] to double (*)[2]. Is this related to the fact that CostType is int? But why can't it be? I will very much appreciate help in understanding what I am doing wrong.

Indeed, the error indicates the weights must be doubles.
That's because the algorithm invokes a linear solver with the raw points, and that's failing because the weight type is not a real number type.
If you change
using CostType = double;
everything compiles fine. Live On Coliru
If you insist, you can use a transformation:
#include <boost/property_map/transform_value_property_map.hpp>
kamada_kawai_spring_layout(g_, temp,
boost::make_transform_value_property_map([](int i) -> double { return i; }, get(edge_bundle, g_)),
square_topology<>(50.0),
side_length(50.0),
layout_tolerance<double>(),
double(1),
propmapIndex);
If you don't want to use the lambda, use a functor:
struct to_double { double operator()(int i) const { return i; } };
kamada_kawai_spring_layout(g_, temp,
boost::make_transform_value_property_map(to_double(), get(edge_bundle, g_)),
square_topology<>(50.0),
side_length(50.0),
layout_tolerance<double>(),
double(1),
propmapIndex);

Related

boost multi_index_container not compiling

Trying to follow the boost docs on the usage of this, but am running into a snag.
Building on CentOS 7, g++ 4.8.5-28. Language standard: C++03
Working sample: https://godbolt.org/z/KPvjS_
My Code:
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/composite_key.hpp>
using namespace ::boost;
using namespace ::boost::multi_index;
typedef unsigned char UInt8;
typedef unsigned int UInt32;
typedef UInt8 ACCESSID[16];
class AccessID
{
public:
AccessID();
AccessID(const AccessID & id);
const std::size_t GetHash() const { return hashId;}
private:
ACCESSID id;
std::size_t hashId;
};
struct map_entry
{
UInt32 subject_hash;
UInt32 container;
AccessID clientAccessId;
AccessID serverAccessId;
map_entry( UInt32 parmHash
, UInt32 parmContainer
, AccessID &parmClientAccessId
, AccessID &parmServerAccessId )
: subject_hash( parmHash )
, container( parmContainer )
, clientAccessId( parmClientAccessId )
, serverAccessId( parmServerAccessId )
{
}
};
struct clientAccessId_extractor
{
typedef std::size_t result_type;
result_type operator ()( const map_entry &e ) const
{
// Hash is a boost::hash value.
return e.clientAccessId.GetHash();
}
};
struct serverAccessId_extractor
{
typedef std::size_t result_type;
result_type operator ()( const map_entry &e ) const
{
return e.serverAccessId.GetHash();
}
};
// Define the mapping relationships; like a "database" of sorts.
typedef multi_index_container<
map_entry,
indexed_by<
// Former "global" view.
ordered_unique<
composite_key<
map_entry,
member< map_entry, UInt32, &map_entry::container >,
serverAccessId_extractor
>
>,
// Regular lookup.
ordered_unique<
composite_key<
map_entry,
member< map_entry, UInt32, &map_entry::subject_hash >,
member< map_entry, UInt32, &map_entry::container >,
clientAccessId_extractor
>
>
>
> mapDb_t;
// Typedef the index types for easier reading.
typedef mapDb_t::nth_index< 0 >::type mapDb_by_serverAid;
typedef mapDb_t::nth_index< 1 >::type mapDb_by_clientAid;
class MappingClass
{
private:
// Index views.
mapDb_by_serverAid serverView;
mapDb_by_clientAid clientView;
// Index iterators.
mapDb_by_clientAid::iterator clientIter;
mapDb_by_serverAid::iterator serverIter;
// Define an object of the mapping db type.
mapDb_t mapDb;
public:
MappingClass() { };
~MappingClass() { };
};
And the error output from trying to compile:
$ g++ -fPIC -x c++ -c -Wno-unused-local-typedefs -Wall -Werror -O2 -m64 -D__EXTENSIONS__ -U_RWSTD_MULTI_THREAD -U_REENTRANT -DUSE_PTHREADS -DNDEBUG -DGCCBOOL -U_THREAD_SAFE -I/home/jearle/git//Open-Source/boost/1.51.0/common test_mi2.cpp -o test_mi2.o
test_mi2.cpp: In constructor ‘MappingClass::MappingClass()’:
test_mi2.cpp:110:20: error: no matching function for call to ‘boost::multi_index::detail::ordered_index<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor>, std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> > >, boost::multi_index::detail::nth_layer<1, map_entry, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> >, boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, std::allocator<map_entry> >, boost::mpl::vector0<mpl_::na>, boost::multi_index::detail::ordered_unique_tag>::ordered_index( ’
MappingClass() { };
^
test_mi2.cpp:110:20: note: candidates are:
In file included from test_mi2.cpp:3:0:
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:542:3: note: boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::ordered_index(const boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>&) [with KeyFromValue = boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor>; Compare = std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> > >; SuperMeta = boost::multi_index::detail::nth_layer<1, map_entry, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> >, boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, std::allocator<map_entry> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag]
ordered_index(
^
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:542:3: note: candidate expects 1 argument, 0 provided
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:534:3: note: boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::ordered_index(const ctor_args_list&, const allocator_type&) [with KeyFromValue = boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor>; Compare = std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> > >; SuperMeta = boost::multi_index::detail::nth_layer<1, map_entry, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> >, boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, std::allocator<map_entry> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag; boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::ctor_args_list = boost::tuples::cons<boost::tuples::tuple<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor>, std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> > >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, boost::tuples::cons<boost::tuples::tuple<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor>, std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, boost::tuples::null_type> >; typename SuperMeta::type::ctor_args_list = boost::tuples::cons<boost::tuples::tuple<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor>, std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, boost::tuples::null_type>; boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::allocator_type = std::allocator<map_entry>]
ordered_index(const ctor_args_list& args_list,const allocator_type& al):
^
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:534:3: note: candidate expects 2 arguments, 0 provided
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:558:3: error: ‘boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::~ordered_index() [with KeyFromValue = boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor>; Compare = std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> > >; SuperMeta = boost::multi_index::detail::nth_layer<1, map_entry, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> >, boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, std::allocator<map_entry> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag]’ is protected
~ordered_index()
^
test_mi2.cpp:110:20: error: within this context
MappingClass() { };
^
test_mi2.cpp:110:20: error: no matching function for call to ‘boost::multi_index::detail::ordered_index<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor>, std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, boost::multi_index::detail::nth_layer<2, map_entry, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> >, boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, std::allocator<map_entry> >, boost::mpl::vector0<mpl_::na>, boost::multi_index::detail::ordered_unique_tag>::ordered_index()’
test_mi2.cpp:110:20: note: candidates are:
In file included from test_mi2.cpp:3:0:
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:542:3: note: boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::ordered_index(const boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>&) [with KeyFromValue = boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor>; Compare = std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >; SuperMeta = boost::multi_index::detail::nth_layer<2, map_entry, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> >, boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, std::allocator<map_entry> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag]
ordered_index(
^
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:542:3: note: candidate expects 1 argument, 0 provided
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:534:3: note: boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::ordered_index(const ctor_args_list&, const allocator_type&) [with KeyFromValue = boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor>; Compare = std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >; SuperMeta = boost::multi_index::detail::nth_layer<2, map_entry, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> >, boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, std::allocator<map_entry> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag; boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::ctor_args_list = boost::tuples::cons<boost::tuples::tuple<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor>, std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, boost::tuples::null_type>; typename SuperMeta::type::ctor_args_list = boost::tuples::null_type; boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::allocator_type = std::allocator<map_entry>]
ordered_index(const ctor_args_list& args_list,const allocator_type& al):
^
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:534:3: note: candidate expects 2 arguments, 0 provided
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:558:3: error: ‘boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::~ordered_index() [with KeyFromValue = boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor>; Compare = std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >; SuperMeta = boost::multi_index::detail::nth_layer<2, map_entry, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> >, boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, std::allocator<map_entry> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag]’ is protected
~ordered_index()
^
test_mi2.cpp:110:20: error: within this context
MappingClass() { };
^
In file included from test_mi2.cpp:3:0:
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp: In destructor ‘MappingClass::~MappingClass()’:
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:558:3: error: ‘boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::~ordered_index() [with KeyFromValue = boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor>; Compare = std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> > >; SuperMeta = boost::multi_index::detail::nth_layer<1, map_entry, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> >, boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, std::allocator<map_entry> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag]’ is protected
~ordered_index()
^
test_mi2.cpp:111:21: error: within this context
~MappingClass() { };
^
In file included from test_mi2.cpp:3:0:
/home/jearle/git//Open-Source/boost/1.51.0/common/boost/multi_index/ordered_index.hpp:558:3: error: ‘boost::multi_index::detail::ordered_index<KeyFromValue, Compare, SuperMeta, TagList, Category>::~ordered_index() [with KeyFromValue = boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor>; Compare = std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >; SuperMeta = boost::multi_index::detail::nth_layer<2, map_entry, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, serverAccessId_extractor> >, boost::multi_index::ordered_unique<boost::multi_index::composite_key<map_entry, boost::multi_index::member<map_entry, unsigned int, &map_entry::subject_hash>, boost::multi_index::member<map_entry, unsigned int, &map_entry::container>, clientAccessId_extractor> > >, std::allocator<map_entry> >; TagList = boost::mpl::vector0<mpl_::na>; Category = boost::multi_index::detail::ordered_unique_tag]’ is protected
~ordered_index()
^
test_mi2.cpp:111:21: error: within this context
~MappingClass() { };
^
I don't really understand what the boost errors are, here. What have I missed?
The map index types are not default constructible, you need to change them to references and initialise them in your constructor:
class MappingClass
{
private:
// Define an object of the mapping db type.
mapDb_t mapDb;
// Index iterators.
mapDb_by_clientAid::iterator clientIter;
mapDb_by_serverAid::iterator serverIter;
// Index views.
mapDb_by_serverAid& serverView;
mapDb_by_clientAid& clientView;
public:
MappingClass()
:serverView( mapDb.get< 0 >() ),
clientView( mapDb.get< 1 >() ) { };
~MappingClass() { };
};
Note you also need to move mapDb to before the views so that it is initialised first.

public empty constructors needed by serialization

I am chasing a rabbit down the hole, by trying to figure out the following:
I do not want empty public constructors (they can, and will create issues)
Two template classes must remain ignorant of each-other, else I will have template parameter cyclic problems
A third class apparently needs access to both previous classes, as it is the one that is being (de)serialized
A minified example is shown below:
template <class s_trait>
class state
{
public:
state(s_trait);
private:
state() = default;
friend class boost::serialization::access;
template <typename archive>
void serialize(archive &, const unsigned int);
};
template <class a_trait>
class action
{
public:
action(a_trait);
private:
action() = default;
friend class boost::serialization::access;
template <typename archive>
void serialize(archive &, const unsigned int);
};
template <class state_type, class action_type>
class policy
{
public:
/// ... some public methods
private:
friend class boost::serialization::access;
std::unordered_map<state_class,
std::unordered_map<action_class,
double>> __policies__;
template <typename archive>
void serialize(archive &, const unsigned int);
};
The above skeleton (without the boring details) has the following design issues:
class state cannot be aware of action, if action is to be aware of state
class action cannot be aware of state and vice versa
class policy templates the state and action on purpose
However, compiling an app using those classes creates issues arising from std::pair, which seem to stem from boost::serialization::access, which in turn appear to be from the fact that class policy needs access to the default empty constructors when calling serialize:
/usr/include/c++/5/bits/stl_pair.h: In instantiation of ‘constexpr std::pair<_T1, _T2>::pair() [with _T1 = const relearn::state<mumbler::state<std::__cxx11::basic_string<char> > >; _T2 = std::unordered_map<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >, double, relearn::hasher<relearn::action<mu
mbler::action<std::__cxx11::basic_string<char> > > >, std::equal_to<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::allocator<std::pair<const relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >, double> > >]’:
/usr/include/boost/serialization/access.hpp:132:9: required from ‘static void boost::serialization::access::construct(T*) [with T = std::pair<const relearn::state<mumbler::state<std::__cxx11::basic_string<char> > >, std::unordered_map<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >, double, rel
earn::hasher<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::equal_to<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::allocator<std::pair<const relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >, double> > > >]’
/usr/include/boost/serialization/serialization.hpp:93:22: required from ‘void boost::serialization::load_construct_data(Archive&, T*, unsigned int) [with Archive = boost::archive::binary_iarchive; T = std::pair<const relearn::state<mumbler::state<std::__cxx11::basic_string<char> > >, std::unordered_map<relearn::act
ion<mumbler::action<std::__cxx11::basic_string<char> > >, double, relearn::hasher<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::equal_to<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::allocator<std::pair<const relearn::action<mumbler::action<std::__cxx11::b
asic_string<char> > >, double> > > >]’
/usr/include/boost/serialization/serialization.hpp:158:28: required from ‘void boost::serialization::load_construct_data_adl(Archive&, T*, unsigned int) [with Archive = boost::archive::binary_iarchive; T = std::pair<const relearn::state<mumbler::state<std::__cxx11::basic_string<char> > >, std::unordered_map<relearn
::action<mumbler::action<std::__cxx11::basic_string<char> > >, double, relearn::hasher<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::equal_to<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::allocator<std::pair<const relearn::action<mumbler::action<std::__cxx
11::basic_string<char> > >, double> > > >]’
/usr/include/boost/serialization/detail/stack_constructor.hpp:54:54: required from ‘boost::serialization::detail::stack_construct<Archive, T>::stack_construct(Archive&, unsigned int) [with Archive = boost::archive::binary_iarchive; T = std::pair<const relearn::state<mumbler::state<std::__cxx11::basic_string<char> >
>, std::unordered_map<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >, double, relearn::hasher<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::equal_to<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::allocator<std::pair<const relearn::act
ion<mumbler::action<std::__cxx11::basic_string<char> > >, double> > > >]’
/usr/include/boost/serialization/unordered_map.hpp:45:55: required from ‘void boost::serialization::stl::archive_input_unordered_map<Archive, Container>::operator()(Archive&, Container&, unsigned int) [with Archive = boost::archive::binary_iarchive; Container = std::unordered_map<relearn::state<mumbler::state<std::
__cxx11::basic_string<char> > >, std::unordered_map<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >, double, relearn::hasher<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::equal_to<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::allocator
<std::pair<const relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >, double> > >, relearn::hasher<relearn::state<mumbler::state<std::__cxx11::basic_string<char> > > >, std::equal_to<relearn::state<mumbler::state<std::__cxx11::basic_string<char> > > >, std::allocator<std::pair<const relearn::state<mu
mbler::state<std::__cxx11::basic_string<char> > >, std::unordered_map<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >, double, relearn::hasher<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >, std::equal_to<relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >
>, std::allocator<std::pair<const relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >, double> > > > > >]’
/usr/include/boost/serialization/unordered_collections_load_imp.hpp:66:14: [ skipping 24 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/boost/archive/detail/iserializer.hpp:618:18: required from ‘void boost::archive::load(Archive&, T&) [with Archive = boost::archive::binary_iarchive; T = relearn::policy<relearn::state<mumbler::state<std::__cxx11::basic_string<char> > >, relearn::action<mumbler::action<std::__cxx11::basic_string<char> >
> >]’
/usr/include/boost/archive/detail/common_iarchive.hpp:66:22: required from ‘void boost::archive::detail::common_iarchive<Archive>::load_override(T&, int) [with T = relearn::policy<relearn::state<mumbler::state<std::__cxx11::basic_string<char> > >, relearn::action<mumbler::action<std::__cxx11::basic_string<char> > >
>; Archive = boost::archive::binary_iarchive]’
/usr/include/boost/archive/basic_binary_iarchive.hpp:76:7: required from ‘void boost::archive::basic_binary_iarchive<Archive>::load_override(T&, int) [with T = relearn::policy<relearn::state<mumbler::state<std::__cxx11::basic_string<char> > >, relearn::action<mumbler::action<std::__cxx11::basic_string<char> > > >;
Archive = boost::archive::binary_iarchive]’
/usr/include/boost/archive/binary_iarchive_impl.hpp:62:9: required from ‘void boost::archive::binary_iarchive_impl<Archive, Elem, Tr>::load_override(T&, int) [with T = relearn::policy<relearn::state<mumbler::state<std::__cxx11::basic_string<char> > >, relearn::action<mumbler::action<std::__cxx11::basic_string<char>
> > >; Archive = boost::archive::binary_iarchive; Elem = char; Tr = std::char_traits<char>]’
/usr/include/boost/archive/detail/interface_iarchive.hpp:60:9: required from ‘Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = relearn::policy<relearn::state<mumbler::state<std::__cxx11::basic_string<char> > >, relearn::action<mumbler::action<std::__cxx11::basic_string<char> >
> >; Archive = boost::archive::binary_iarchive]’
/home/alex/codez/mumbler/src/agent.cpp:9:11: required from here
/home/alex/codez/mumbler/src/relearn/src/relearn.hpp:90:5: error: ‘relearn::state<state_trait, value_type>::state() [with state_trait = mumbler::state<std::__cxx11::basic_string<char> >; value_type = double]’ is private
state() = default;
As far as I can see, I have two options:
leave a public empty default constructor
forward-declare class policy, then befriend it - however this creates the issue that the classes befriending it need be aware of its template parameters, thus they need to be aware of each-other (state-action) which is what I would like to avoid.
Is there some other way to go around this without exposing public empty constructors?
edit
This is not a duplicate, I know how to (de)serialize, the question is about hiding the default constructor for only the (de)serializer to have access to it.
Make your default constructors protected, then make a derived class from each that has a public constructor but hide those derived classes from the outside entirely (put them in a detail header file that nobody else includes). Then your policy class can use the derived classes internally, for serialization and storage, but only expose them as (sliced) base class objects.

Forming reference to void when getting property map from a bundled property

My Graph type is defined as follows:
using Graph = boost::adjacency_list<vecS, setS, directedS, State, CostType>;
where CostType happens to be int.
I am trying to obtain the Kamada-Kawai spring layout as follows:
template <class PointMap>
PointMap layout() const {
PointMap res;
boost::associative_property_map<PointMap> temp(res);
circle_graph_layout(g_, temp, 10.0);
// http://www.boost.org/doc/libs/1_59_0/libs/graph/doc/bundles.html
bool ok = kamada_kawai_spring_layout(
g_, temp, get(edge_bundle, g_),
square_topology<>(50.0), side_length(50.0));
(void)ok;
//boost::BOOST_CHECK(ok);
return res;
}
The compiler (gcc version 4.8.2) complains about creating a reference to void. I have checked that the circular layout works. What am I doing wrong in the call to kamada_kawai_spring_layout?
Here is a partial output by gcc:
-*- mode: compilation; default-directory: "~/SearchLib/AstarWithPolicies/" -*-
Compilation started at Tue Nov 24 22:54:48
make -k
g++ -Wall -Wextra -Werror -std=c++11 -pedantic -I ~/boost_1_59_0 -I /usr/include/cairomm-1.0/ -I /usr/include/cairo/ -I /usr/include/sigc++-2.0/ -I /usr/lib/x86_64-linux-gnu/sigc++-2.0/include/ -I /usr/include/freetype2/ -o Test Test.cpp -g -lcairo -lX11
In file included from /home/meir/boost_1_59_0/boost/graph/adjacency_list.hpp:246:0,
from Graph.h:10,
from Astar.h:5,
from Test.cpp:4:
/home/meir/boost_1_59_0/boost/graph/detail/adjacency_list.hpp: In instantiation of ‘struct boost::adj_list_any_vertex_pa::bind_<boost::vertex_index_t, boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, Pancake>’:
/home/meir/boost_1_59_0/boost/graph/detail/adjacency_list.hpp:2613:12: required from ‘struct boost::detail::adj_list_choose_vertex_pa<boost::vertex_index_t, boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, Pancake>’
/home/meir/boost_1_59_0/boost/graph/detail/adjacency_list.hpp:2750:12: required from ‘struct boost::adj_list_vertex_property_selector::bind_<boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, Pancake, boost::vertex_index_t>’
/home/meir/boost_1_59_0/boost/graph/properties.hpp:201:12: required from ‘struct boost::detail::vertex_property_map<boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, boost::vertex_index_t>’
/home/meir/boost_1_59_0/boost/graph/properties.hpp:212:10: required from ‘struct boost::property_map<boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, boost::vertex_index_t, void>’
/home/meir/boost_1_59_0/boost/graph/detail/adjacency_list.hpp:1733:5: required by substitution of ‘template<class Config, class Base, class Property> typename boost::property_map<typename Config::graph_type, Property>::const_type boost::get(Property, const boost::adj_list_helper<Config, Base>&) [with Config = boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, boost::setS, boost::vecS, boost::directedS, Pancake, int, boost::no_property, boost::listS>::config; Base = boost::directed_graph_helper<boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, boost::setS, boost::vecS, boost::directedS, Pancake, int, boost::no_property, boost::listS>::config>; Property = boost::vertex_index_t]’
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:618:58: required from ‘bool boost::kamada_kawai_spring_layout(const Graph&, PositionMap, WeightMap, const Topology&, boost::detail::graph::edge_or_side<EdgeOrSideLength, T>) [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, int, const int&, void*, const int, boost::edge_bundle_t>; T = double; bool EdgeOrSideLength = false]’
Graph.h:106:55: required from ‘PointMap StateGraph<StateNeighbor>::layout() const [with PointMap = std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > >; StateNeighbor = StateNeighbor<Pancake>]’
Drawer.h:60:75: required from ‘Drawer<Graph>::Drawer(const Graph&) [with Graph = StateGraph<StateNeighbor<Pancake> >]’
Test.cpp:34:22: required from here
/home/meir/boost_1_59_0/boost/graph/detail/adjacency_list.hpp:2543:29: error: forming reference to void
typedef value_type& reference;
UPDATE 1: the same error occurs if I change the graph type to undirectedS.
UPDATE 2: Thanks to the comments, this is the improved version that uses an index map:
template <class PointMap>
PointMap layout() const {
PointMap res;
boost::associative_property_map<PointMap> temp(res);
circle_graph_layout(g_, temp, 10.0);
// https://stackoverflow.com/q/33903879/2725810
// https://stackoverflow.com/a/8555715/2725810
typedef std::map<VertexDescriptor, std::size_t> IndexMap;
IndexMap mapIndex;
associative_property_map<IndexMap> propmapIndex(mapIndex);
// http://www.boost.org/doc/libs/1_59_0/libs/graph/doc/bundles.html
kamada_kawai_spring_layout(g_, temp, get(edge_bundle, g_),
square_topology<>(50.0), side_length(50.0),
layout_tolerance<CostType>(),
CostType(1), propmapIndex);
return res;
}
This still does not satisfy gcc though:
In file included from Graph.h:13:0,
from Astar.h:5,
from Test.cpp:4:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp: In instantiation of ‘bool boost::detail::graph::kamada_kawai_spring_layout_impl<Topology, Graph, PositionMap, WeightMap, EdgeOrSideLength, Done, VertexIndexMap, DistanceMatrix, SpringStrengthMatrix, PartialDerivativeMap>::run() [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>; EdgeOrSideLength = boost::detail::graph::edge_or_side<false, double>; Done = boost::layout_tolerance<int>; VertexIndexMap = boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >; DistanceMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; SpringStrengthMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; PartialDerivativeMap = boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&>]’:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:524:20: required from ‘bool boost::kamada_kawai_spring_layout(const Graph&, PositionMap, WeightMap, const Topology&, boost::detail::graph::edge_or_side<EdgeOrSideLength, T>, Done, typename boost::property_traits<DistanceMap>::value_type, VertexIndexMap, DistanceMatrix, SpringStrengthMatrix, PartialDerivativeMap) [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>; T = double; bool EdgeOrSideLength = false; Done = boost::layout_tolerance<int>; VertexIndexMap = boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >; DistanceMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; SpringStrengthMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; PartialDerivativeMap = boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&>; typename boost::property_traits<DistanceMap>::value_type = int]’
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:559:79: required from ‘bool boost::kamada_kawai_spring_layout(const Graph&, PositionMap, WeightMap, const Topology&, boost::detail::graph::edge_or_side<EdgeOrSideLength, T>, Done, typename boost::property_traits<DistanceMap>::value_type, VertexIndexMap) [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>; T = double; bool EdgeOrSideLength = false; Done = boost::layout_tolerance<int>; VertexIndexMap = boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >; typename boost::property_traits<DistanceMap>::value_type = int]’
Graph.h:112:61: required from ‘PointMap StateGraph<StateNeighbor>::layout() const [with PointMap = std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > >; StateNeighbor = StateNeighbor<Pancake>]’
Drawer.h:60:75: required from ‘Drawer<Graph>::Drawer(const Graph&) [with Graph = StateGraph<StateNeighbor<Pancake> >]’
Test.cpp:34:22: required from here
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:313:96: error: no matching function for call to ‘boost::detail::graph::linear_solver<2ul>::solve(boost::detail::graph::kamada_kawai_spring_layout_impl<boost::square_topology<>, boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>, boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >, boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>, boost::detail::graph::edge_or_side<false, double>, boost::layout_tolerance<int>, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&> >::weight_type [2][2], boost::detail::graph::kamada_kawai_spring_layout_impl<boost::square_topology<>, boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>, boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >, boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>, boost::detail::graph::edge_or_side<false, double>, boost::layout_tolerance<int>, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&> >::deriv_type&)’
_difference_type delta = -linear_solver<Point::dimensions>::solve(dE_d_d, dE_d);
^
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:313:96: note: candidate is:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:95:18: note: template<class Vec> static Vec boost::detail::graph::linear_solver<2ul>::solve(double (*)[2], Vec)
static Vec solve(double mat[2][2], Vec rhs) {
^
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:95:18: note: template argument deduction/substitution failed:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:313:96: note: cannot convert ‘dE_d_d’ (type ‘boost::detail::graph::kamada_kawai_spring_layout_impl<boost::square_topology<>, boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>, boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >, boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>, boost::detail::graph::edge_or_side<false, double>, boost::layout_tolerance<int>, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&> >::weight_type [2][2] {aka int [2][2]}’) to type ‘double (*)[2]’
_difference_type delta = -linear_solver<Point::dimensions>::solve(dE_d_d, dE_d);
EDIT: Since this has become a different question, I started a new question here.

dijkstra_shortest_paths Boost Graph Lib 1.57.0 fails

I am using BGL and have recently migrated to 1.57.0 from 1.46.1. I also switched from using Xcode on a mac to gcc 4.9.2.
I am getting a no matching function call to get and have created this small snipet of code to illustrate the problem. If I change the INCLUDE path to be 1.46.1, this code works great, its on 1.55.0 and 1.57.0 that it fails.
Any advice appreciated.
Thanks.
#include <boost/config.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/connected_components.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
struct EdgeDef
{
double dist;
double prop1;
};
typedef boost::adjacency_list < boost::listS, boost::vecS, boost::directedS,boost::no_property,EdgeDef > Graph;
int main() {
Graph g;
std::vector<double> d(num_vertices(g));
std::vector<Graph::vertex_descriptor> p(num_vertices(g));
Graph::vertex_descriptor s = 0;
dijkstra_shortest_paths(g,s,
boost::predecessor_map(&p[0]).distance_map(&d[0]).
weight_map(get(&EdgeDef::dist,g)));
}
Error log from building with gcc
2:37:37 **** Incremental Build of configuration Debug for project TestBGL ****
make all
Building file: ../src/TestBGL.cpp
Invoking: GCC C++ Compiler
/usr/local/bin/g++-4.9 -I/Users/flyboy777/Downloads/boost_1_57_0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TestBGL.d" -MT"src/TestBGL.d" -o "src/TestBGL.o" "../src/TestBGL.cpp"
In file included from ../src/TestBGL.cpp:6:0:
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp: In instantiation of 'void boost::detail::dijkstra_bfs_visitor<UniformCostVisitor, UpdatableQueue, WeightMap, PredecessorMap, DistanceMap, BinaryFunction, BinaryPredicate>::gray_target(Edge, Graph&) [with Edge = boost::detail::edge_desc_impl<boost::directed_tag, long unsigned int>; Graph = const boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; UniformCostVisitor = boost::dijkstra_visitor<>; UpdatableQueue = boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; PredecessorMap = long unsigned int*; DistanceMap = double*; BinaryFunction = boost::closed_plus<double>; BinaryPredicate = std::less<double>]':
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/breadth_first_search.hpp:87:47: required from 'void boost::breadth_first_visit(const IncidenceGraph&, SourceIterator, SourceIterator, Buffer&, BFSVisitor, ColorMap) [with IncidenceGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; Buffer = boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >; BFSVisitor = boost::detail::dijkstra_bfs_visitor<boost::dijkstra_visitor<>, boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >, boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, long unsigned int*, double*, boost::closed_plus<double>, std::less<double> >; ColorMap = boost::two_bit_color_map<boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int> >; SourceIterator = long unsigned int*]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:383:61: required from 'void boost::dijkstra_shortest_paths_no_init(const Graph&, SourceInputIter, SourceInputIter, PredecessorMap, DistanceMap, WeightMap, IndexMap, Compare, Combine, DistZero, DijkstraVisitor, ColorMap) [with Graph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; SourceInputIter = long unsigned int*; DijkstraVisitor = boost::dijkstra_visitor<>; PredecessorMap = long unsigned int*; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Compare = std::less<double>; Combine = boost::closed_plus<double>; DistZero = double; ColorMap = boost::two_bit_color_map<boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int> >]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:478:34: required from 'void boost::dijkstra_shortest_paths(const VertexListGraph&, SourceInputIter, SourceInputIter, PredecessorMap, DistanceMap, WeightMap, IndexMap, Compare, Combine, DistInf, DistZero, DijkstraVisitor, ColorMap) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; SourceInputIter = long unsigned int*; DijkstraVisitor = boost::dijkstra_visitor<>; PredecessorMap = long unsigned int*; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Compare = std::less<double>; Combine = boost::closed_plus<double>; DistInf = double; DistZero = double; ColorMap = boost::two_bit_color_map<boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int> >]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:425:34: required from 'void boost::dijkstra_shortest_paths(const VertexListGraph&, SourceInputIter, SourceInputIter, PredecessorMap, DistanceMap, WeightMap, IndexMap, Compare, Combine, DistInf, DistZero, DijkstraVisitor, const boost::bgl_named_params<T, Tag, Base>&, typename boost::enable_if_c<boost::is_base_and_derived<boost::vertex_list_graph_tag, typename boost::graph_traits<Graph>::traversal_category>::value, boost::graph::detail::no_parameter>::type) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; SourceInputIter = long unsigned int*; DijkstraVisitor = boost::dijkstra_visitor<>; PredecessorMap = long unsigned int*; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Compare = std::less<double>; Combine = boost::closed_plus<double>; DistInf = double; DistZero = double; T = char; Tag = boost::detail::unused_tag_type; Base = boost::no_property; typename boost::enable_if_c<boost::is_base_and_derived<boost::vertex_list_graph_tag, typename boost::graph_traits<Graph>::traversal_category>::value, boost::graph::detail::no_parameter>::type = boost::graph::detail::no_parameter]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:518:50: required from 'void boost::dijkstra_shortest_paths(const VertexListGraph&, SourceInputIter, SourceInputIter, PredecessorMap, DistanceMap, WeightMap, IndexMap, Compare, Combine, DistInf, DistZero, DijkstraVisitor) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; SourceInputIter = long unsigned int*; DijkstraVisitor = boost::dijkstra_visitor<>; PredecessorMap = long unsigned int*; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Compare = std::less<double>; Combine = boost::closed_plus<double>; DistInf = double; DistZero = double]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:446:72: required from 'void boost::dijkstra_shortest_paths(const VertexListGraph&, typename boost::graph_traits<Graph>::vertex_descriptor, PredecessorMap, DistanceMap, WeightMap, IndexMap, Compare, Combine, DistInf, DistZero, DijkstraVisitor, const boost::bgl_named_params<T, Tag, Base>&, typename boost::enable_if_c<boost::is_base_and_derived<boost::vertex_list_graph_tag, typename boost::graph_traits<Graph>::traversal_category>::value, boost::graph::detail::no_parameter>::type) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; DijkstraVisitor = boost::dijkstra_visitor<>; PredecessorMap = long unsigned int*; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Compare = std::less<double>; Combine = boost::closed_plus<double>; DistInf = double; DistZero = double; T = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; Tag = boost::edge_weight_t; Base = boost::bgl_named_params<double*, boost::vertex_distance_t, boost::bgl_named_params<long unsigned int*, boost::vertex_predecessor_t, boost::no_property> >; typename boost::graph_traits<Graph>::vertex_descriptor = long unsigned int; typename boost::enable_if_c<boost::is_base_and_derived<boost::vertex_list_graph_tag, typename boost::graph_traits<Graph>::traversal_category>::value, boost::graph::detail::no_parameter>::type = boost::graph::detail::no_parameter]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:573:16: required from 'void boost::detail::dijkstra_dispatch2(const VertexListGraph&, typename boost::graph_traits<Graph>::vertex_descriptor, DistanceMap, WeightMap, IndexMap, const Params&) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Params = boost::bgl_named_params<boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, boost::edge_weight_t, boost::bgl_named_params<double*, boost::vertex_distance_t, boost::bgl_named_params<long unsigned int*, boost::vertex_predecessor_t, boost::no_property> > >; typename boost::graph_traits<Graph>::vertex_descriptor = long unsigned int]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:595:35: required from 'void boost::detail::dijkstra_dispatch1(const VertexListGraph&, typename boost::graph_traits<Graph>::vertex_descriptor, DistanceMap, WeightMap, IndexMap, const Params&) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Params = boost::bgl_named_params<boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, boost::edge_weight_t, boost::bgl_named_params<double*, boost::vertex_distance_t, boost::bgl_named_params<long unsigned int*, boost::vertex_predecessor_t, boost::no_property> > >; typename boost::graph_traits<Graph>::vertex_descriptor = long unsigned int]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:614:14: required from 'void boost::dijkstra_shortest_paths(const VertexListGraph&, typename boost::graph_traits<Graph>::vertex_descriptor, const boost::bgl_named_params<T, Tag, Base>&) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; Param = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; Tag = boost::edge_weight_t; Rest = boost::bgl_named_params<double*, boost::vertex_distance_t, boost::bgl_named_params<long unsigned int*, boost::vertex_predecessor_t, boost::no_property> >; typename boost::graph_traits<Graph>::vertex_descriptor = long unsigned int]'
../src/TestBGL.cpp:26:62: required from here
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:141:54: error: no matching function for call to 'get(double*&, long unsigned int)'
D old_distance = get(m_distance, target(e, g));
^
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:141:54: note: candidate is:
In file included from /Users/flyboy777/Downloads/boost_1_57_0/boost/graph/transpose_graph.hpp:16:0,
from /Users/flyboy777/Downloads/boost_1_57_0/boost/graph/strong_components.hpp:262,
from ../src/TestBGL.cpp:5:
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/reverse_graph.hpp:433:3: note: template<class E> E boost::detail::get(boost::detail::underlying_edge_desc_map_type<E>, const boost::detail::reverse_graph_edge_descriptor<EdgeDesc>&)
get(underlying_edge_desc_map_type<E> m,
^
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/reverse_graph.hpp:433:3: note: template argument deduction/substitution failed:
In file included from ../src/TestBGL.cpp:6:0:
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:141:54: note: mismatched types 'boost::detail::underlying_edge_desc_map_type<E>' and 'double*'
D old_distance = get(m_distance, target(e, g));
^
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp: In instantiation of 'void boost::detail::dijkstra_bfs_visitor<UniformCostVisitor, UpdatableQueue, WeightMap, PredecessorMap, DistanceMap, BinaryFunction, BinaryPredicate>::gray_target(Edge, Graph&) [with Edge = boost::detail::edge_desc_impl<boost::directed_tag, long unsigned int>; Graph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; UniformCostVisitor = boost::dijkstra_visitor<>; UpdatableQueue = boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; PredecessorMap = long unsigned int*; DistanceMap = double*; BinaryFunction = boost::closed_plus<double>; BinaryPredicate = std::less<double>]':
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/breadth_first_search.hpp:45:7: required from 'void boost::BFSVisitorConcept<Visitor, Graph>::constraints() [with Visitor = boost::detail::dijkstra_bfs_visitor<boost::dijkstra_visitor<>, boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >, boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, long unsigned int*, double*, boost::closed_plus<double>, std::less<double> >; Graph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/concept/detail/has_constraints.hpp:32:62: required by substitution of 'template<class Model> boost::concepts::detail::yes boost::concepts::detail::has_constraints_(Model*, boost::concepts::detail::wrap_constraints<Model, (& Model:: constraints)>*) [with Model = boost::BFSVisitorConcept<boost::detail::dijkstra_bfs_visitor<boost::dijkstra_visitor<>, boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >, boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, long unsigned int*, double*, boost::closed_plus<double>, std::less<double> >, boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef> >]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/concept/detail/has_constraints.hpp:42:5: required from 'const bool boost::concepts::not_satisfied<boost::BFSVisitorConcept<boost::detail::dijkstra_bfs_visitor<boost::dijkstra_visitor<>, boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >, boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, long unsigned int*, double*, boost::closed_plus<double>, std::less<double> >, boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef> > >::value'
/Users/flyboy777/Downloads/boost_1_57_0/boost/concept/detail/has_constraints.hpp:45:31: required from 'struct boost::concepts::not_satisfied<boost::BFSVisitorConcept<boost::detail::dijkstra_bfs_visitor<boost::dijkstra_visitor<>, boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >, boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, long unsigned int*, double*, boost::closed_plus<double>, std::less<double> >, boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef> > >'
/Users/flyboy777/Downloads/boost_1_57_0/boost/mpl/if.hpp:67:11: required from 'struct boost::mpl::if_<boost::concepts::not_satisfied<boost::BFSVisitorConcept<boost::detail::dijkstra_bfs_visitor<boost::dijkstra_visitor<>, boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >, boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, long unsigned int*, double*, boost::closed_plus<double>, std::less<double> >, boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef> > >, boost::concepts::constraint<boost::BFSVisitorConcept<boost::detail::dijkstra_bfs_visitor<boost::dijkstra_visitor<>, boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >, boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, long unsigned int*, double*, boost::closed_plus<double>, std::less<double> >, boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef> > >, boost::concepts::requirement<boost::concepts::failed************ boost::BFSVisitorConcept<boost::detail::dijkstra_bfs_visitor<boost::dijkstra_visitor<>, boost::d_ary_heap_indirect<long unsigned int, 4ul, boost::iterator_property_map<long unsigned int*, boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>, long unsigned int, long unsigned int&>, double*, std::less<double>, std::vector<long unsigned int> >, boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, long unsigned int*, double*, boost::closed_plus<double>, std::less<double> >, boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef> >::************> >'
/Users/flyboy777/Downloads/boost_1_57_0/boost/concept/detail/general.hpp:50:8: [ skipping 5 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:518:50: required from 'void boost::dijkstra_shortest_paths(const VertexListGraph&, SourceInputIter, SourceInputIter, PredecessorMap, DistanceMap, WeightMap, IndexMap, Compare, Combine, DistInf, DistZero, DijkstraVisitor) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; SourceInputIter = long unsigned int*; DijkstraVisitor = boost::dijkstra_visitor<>; PredecessorMap = long unsigned int*; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Compare = std::less<double>; Combine = boost::closed_plus<double>; DistInf = double; DistZero = double]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:446:72: required from 'void boost::dijkstra_shortest_paths(const VertexListGraph&, typename boost::graph_traits<Graph>::vertex_descriptor, PredecessorMap, DistanceMap, WeightMap, IndexMap, Compare, Combine, DistInf, DistZero, DijkstraVisitor, const boost::bgl_named_params<T, Tag, Base>&, typename boost::enable_if_c<boost::is_base_and_derived<boost::vertex_list_graph_tag, typename boost::graph_traits<Graph>::traversal_category>::value, boost::graph::detail::no_parameter>::type) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; DijkstraVisitor = boost::dijkstra_visitor<>; PredecessorMap = long unsigned int*; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Compare = std::less<double>; Combine = boost::closed_plus<double>; DistInf = double; DistZero = double; T = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; Tag = boost::edge_weight_t; Base = boost::bgl_named_params<double*, boost::vertex_distance_t, boost::bgl_named_params<long unsigned int*, boost::vertex_predecessor_t, boost::no_property> >; typename boost::graph_traits<Graph>::vertex_descriptor = long unsigned int; typename boost::enable_if_c<boost::is_base_and_derived<boost::vertex_list_graph_tag, typename boost::graph_traits<Graph>::traversal_category>::value, boost::graph::detail::no_parameter>::type = boost::graph::detail::no_parameter]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:573:16: required from 'void boost::detail::dijkstra_dispatch2(const VertexListGraph&, typename boost::graph_traits<Graph>::vertex_descriptor, DistanceMap, WeightMap, IndexMap, const Params&) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Params = boost::bgl_named_params<boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, boost::edge_weight_t, boost::bgl_named_params<double*, boost::vertex_distance_t, boost::bgl_named_params<long unsigned int*, boost::vertex_predecessor_t, boost::no_property> > >; typename boost::graph_traits<Graph>::vertex_descriptor = long unsigned int]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:595:35: required from 'void boost::detail::dijkstra_dispatch1(const VertexListGraph&, typename boost::graph_traits<Graph>::vertex_descriptor, DistanceMap, WeightMap, IndexMap, const Params&) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; DistanceMap = double*; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; IndexMap = boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>; Params = boost::bgl_named_params<boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>, boost::edge_weight_t, boost::bgl_named_params<double*, boost::vertex_distance_t, boost::bgl_named_params<long unsigned int*, boost::vertex_predecessor_t, boost::no_property> > >; typename boost::graph_traits<Graph>::vertex_descriptor = long unsigned int]'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:614:14: required from 'void boost::dijkstra_shortest_paths(const VertexListGraph&, typename boost::graph_traits<Graph>::vertex_descriptor, const boost::bgl_named_params<T, Tag, Base>&) [with VertexListGraph = boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, EdgeDef>; Param = boost::adj_list_edge_property_map<boost::directed_tag, double, double&, long unsigned int, EdgeDef, double EdgeDef::*>; Tag = boost::edge_weight_t; Rest = boost::bgl_named_params<double*, boost::vertex_distance_t, boost::bgl_named_params<long unsigned int*, boost::vertex_predecessor_t, boost::no_property> >; typename boost::graph_traits<Graph>::vertex_descriptor = long unsigned int]'
../src/TestBGL.cpp:26:62: required from here
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:141:54: error: no matching function for call to 'get(double*&, long unsigned int)'
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:141:54: note: candidate is:
In file included from /Users/flyboy777/Downloads/boost_1_57_0/boost/graph/transpose_graph.hpp:16:0,
from /Users/flyboy777/Downloads/boost_1_57_0/boost/graph/strong_components.hpp:262,
from ../src/TestBGL.cpp:5:
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/reverse_graph.hpp:433:3: note: template<class E> E boost::detail::get(boost::detail::underlying_edge_desc_map_type<E>, const boost::detail::reverse_graph_edge_descriptor<EdgeDesc>&)
get(underlying_edge_desc_map_type<E> m,
^
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/reverse_graph.hpp:433:3: note: template argument deduction/substitution failed:
In file included from ../src/TestBGL.cpp:6:0:
/Users/flyboy777/Downloads/boost_1_57_0/boost/graph/dijkstra_shortest_paths.hpp:141:54: note: mismatched types 'boost::detail::underlying_edge_desc_map_type<E>' and 'double*'
D old_distance = get(m_distance, target(e, g));
^
make: *** [src/TestBGL.o] Error 1
22:37:39 Build Finished (took 2s.330ms)
You should update your code according to changes in property maps in 1.55.
Use make_iterator_property_map instead of raw pointers:
dijkstra_shortest_paths(g,s,
boost::predecessor_map(boost::make_iterator_property_map(p.begin(), get(boost::vertex_index, g))).
distance_map(boost::make_iterator_property_map(d.begin(), get(boost::vertex_index, g))).
weight_map(get(&EdgeDef::dist,g)));
See changes in 1.55 and this bug https://svn.boost.org/trac/boost/ticket/7877

How to iterate a C++ map of maps

I have a map of map
std::map< int, std::map<string, double> > myMap;
std::map< int, std::map<string, double> >::iterator itr;
Iterating it with:
itr = myMap.find(nodeI);
if (itr == myMap.end())
{
exit(1) ;
}
results in the error:
error: no match for âoperator=â in
âitr = ((const PushList*)this)->PushList::myMap.std::map&lt:_Key, _Tp, _Compare, _Alloc>::find
[with _Key = int, _Tp = std::map&lt:std::basic_string&lt:char, std::char_traits&lt:char>,
std::allocator&lt:char> >, double, std::less&lt:std::basic_string&lt:char,
std::char_traits&lt:char>,
std::allocator&lt:char> > >, std::allocator&lt:std::pair&lt:const std::basic_string&lt:char,
std::char_traits&lt:char>, std::allocator&lt:char> >, double> > >, _Compare =
std::less&lt:int>, _Alloc =
std::allocator&lt:std::pair&lt:const int, std::map&lt:std::basic_string&lt:char,
std::char_traits&lt:char>,
std::allocator&lt:char> >, double, std::less&lt:std::basic_string&lt:char,
std::char_traits&lt:char>,
std::allocator&lt:char> > >, std::allocator&lt:std::pair&lt:const std::basic_string&lt:char,
std::char_traits&lt:char>, std::allocator&lt:char> >, double> > > > >](((const
int&)((const int*)((int*)nodeI))))â
How can I iterate the map of map?
From the error you posted it can be seen that you are doing this from within a class member const function. Is there any chance that myMap happens to be a member of that class? If so, what you want is to use const_iterator instead. You should do it anyways, since you are not expecting to modify the contents of the iterated elements.