JohnCoconut / boost_graph_cookbook_1

A well-connected C++14 Boost.Graph tutorial
http://richelbilderbeek.nl/CppBoostGraphTutorial.htm
GNU General Public License v3.0
0 stars 0 forks source link

redundant template parameter #1

Closed JohnCoconut closed 6 years ago

JohnCoconut commented 6 years ago

Algorithm 40 has a redundant template parameter vertex_descriptor. It can be replaced by typename boost::graph_traits<graph>::vertex_descriptor.

#include <boost/graph/adjacency_list.hpp>

template <
  typename graph,
  typename vertex_descriptor
>
typename boost::graph_traits<graph>::edge_descriptor
get_edge_between_vertices(
  const vertex_descriptor& vd_from,
  const vertex_descriptor& vd_to,
  const graph& g
)
{
  const auto er = edge(vd_from, vd_to, g);
  if (!er.second)
  {
    std::stringstream msg;
    msg << __func__ << ": "
      << "no edge between these vertices"
    ;
    throw std::invalid_argument(msg.str());
  }
  return er.first;
}
richelbilderbeek commented 6 years ago

I agree (as often is the case on your review). I assume used the -I agree- redundant template type for a reason, but time may have been a factor as well.

Let's hope Travis CI does its thing again fast (I check on a daily basis), to get your suggestions in.

Keep up the great work!