Vertex property `vertex_index_t` silently discarded when `vecS` selector used vertex list

オープン
#420 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
cpp

調査の方向性

まず、示されている boost::adjacency_list と vertex_index_t property_map のセットアップで static assertion を再現し、次に頂点セレクター vecS と listS に対する property_map の動作を比較します。関係する adjacency_list と property_map のエントリポイントを確認し、一貫した value_type の契約を決定します。完了条件は、宣言された頂点プロパティ型を暗黙に破棄することなく、汎用的なユースケースで定義済みの互換性のある動作が得られることです。

索引モデルが issue の本文から書いたものです。

説明

data structure priority: low

As in the title.

Consider the following code

#include <boost/graph/adjacency_list.hpp>
#include <boost/property_map/property_map.hpp>
#include <type_traits>
#include <vector>

typedef int v_index;
typedef long e_index;

typedef boost::adjacency_list<
    boost::vecS,              // OutEdgeList
    boost::vecS,              // VertexList
    boost::undirectedS,       // DirectedS
    boost::property<boost::vertex_index_t, v_index>, // Vertex property.
    boost::no_property,       // Edge property (can be enhanced if needed).
    boost::no_property,       // Graph property.
    boost::vecS               // EdgeList
> Graph;

typedef boost::property_map<Graph, boost::vertex_index_t>::type vertex_to_int_map;

static_assert(std::is_same_v<typename vertex_to_int_map::value_type, v_index>,
              "The vertex property map's value type must be v_index");

The static assertion fails. Changing VertexList to e.g. boost::listS makes it pass.

This causes a little problem in generic code which assumes the type returned by the vertex_to_int_map property map is equal to v_index. For example https://github.com/sagemath/sage/pull/39526 .

Not sure what's the best course of action here. I think the easiest one would be to make the property map just cast the result to the correct type (assume it can be casted of course, but what if the user specifies something weird like std::string?)

主要言語
C++
スター
402
フォーク
251
平均マージ
1日 9時間
マージ済み PR(30日)
38

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

boostorg/graph のほかの issue

boostorg/graph の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。