Not sure this is a very helpful issue, as I am still catching up on Boost Concepts, but I will drop it for the record and discussion
Problem 1: Algorithms that perform no check at all
When a user passes a property map with the wrong category to an algorithm, the compiler error is deeply nested and unhelpful.
For example, passing a read-only distance property map to dijkstra fails to compile with a long and rather cryptic error, ending with
app/boost/include/boost/property_map/property_map.hpp:311:40: error: lvalue required as left operand of assignment
311 | static_cast<const PropertyMap&>(pa)[k] = v;
See on Compiler Explorer
Problem 2: Algorithms that check boost concepts
Some algorithms like Bellman use Boost Concepts to check the property map category, but the output is actually worse than no check.
See on compiler explorer
Proposal
I guess the use of Boost Concepts is justified by pre-C++11 static_assert. Also for documentation purpose. But maybe we should open a conversation on making compilation error messages more clear.
Maybe add static_assert checks for property map categories in algorithms that currently lack them:
static_assert(
std::is_convertible<
typename property_traits<DistanceMap>::category,
read_write_property_map_tag>::value,
"distance_map must be a ReadWrite property map (supports both get and put)");
This produces a single line error:
error: static_assert failed "distance_map must be a ReadWrite property map
(supports both get and put)"
See on Compiler Explorer
Not sure this is a very helpful issue, as I am still catching up on Boost Concepts, but I will drop it for the record and discussion
Problem 1: Algorithms that perform no check at all
When a user passes a property map with the wrong category to an algorithm, the compiler error is deeply nested and unhelpful.
For example, passing a read-only distance property map to dijkstra fails to compile with a long and rather cryptic error, ending with
See on Compiler Explorer
Problem 2: Algorithms that check boost concepts
Some algorithms like Bellman use Boost Concepts to check the property map category, but the output is actually worse than no check.
See on compiler explorer
Proposal
I guess the use of Boost Concepts is justified by pre-C++11
static_assert. Also for documentation purpose. But maybe we should open a conversation on making compilation error messages more clear.Maybe add
static_assertchecks for property map categories in algorithms that currently lack them:This produces a single line error:
See on Compiler Explorer