Skip to content

Commit

Permalink
C++11: graph_selectors: Remove true/false_type types.
Browse files Browse the repository at this point in the history
And use just the true/false values, via constexpr, avoiding
the need for std::negation and std::conjunction.
  • Loading branch information
murraycu committed May 16, 2017
1 parent ea4d604 commit baacbb6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 31 deletions.
17 changes: 8 additions & 9 deletions include/boost/graph/adjacency_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ namespace boost {
struct adjacency_list_traits
{
static constexpr bool is_rand_access = detail::is_random_access<VertexListS>::value;
typedef typename DirectedS::is_bidir_t is_bidir;
typedef typename DirectedS::is_directed_t is_directed;
static constexpr bool is_bidir = DirectedS::is_bidir;
static constexpr bool is_directed = DirectedS::is_directed;

typedef typename std::conditional<is_bidir::value,
typedef typename std::conditional<is_bidir,
bidirectional_tag,
typename std::conditional<is_directed::value,
typename std::conditional<is_directed,
directed_tag, undirected_tag
>::type
>::type directed_category;
Expand All @@ -200,12 +200,11 @@ namespace boost {
// Logic to figure out the edges_size_type
struct dummy {};
typedef typename container_gen<EdgeListS, dummy>::type EdgeContainer;
typedef typename DirectedS::is_bidir_t BidirectionalT;
typedef typename DirectedS::is_directed_t DirectedT;
typedef typename std::conjunction<DirectedT,
typename std::negation<BidirectionalT>::type >::type on_edge_storage;
static constexpr bool BidirectionalT = DirectedS::is_bidir;
static constexpr bool DirectedT = DirectedS::is_directed;
static constexpr bool on_edge_storage = DirectedT && !BidirectionalT;
public:
typedef typename std::conditional<on_edge_storage::value,
typedef typename std::conditional<on_edge_storage,
std::size_t, typename EdgeContainer::size_type
>::type edges_size_type;

Expand Down
4 changes: 2 additions & 2 deletions include/boost/graph/adjacency_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,15 @@ namespace boost {
// Adjacency Matrix Traits
template <typename Directed = directedS>
class adjacency_matrix_traits {
typedef typename Directed::is_directed_t is_directed;
static constexpr bool is_directed = Directed::is_directed;
public:
// The bidirectionalS tag is not allowed with the adjacency_matrix
// graph type. Instead, use directedS, which also provides the
// functionality required for a Bidirectional Graph (in_edges,
// in_degree, etc.).
BOOST_STATIC_ASSERT(!(std::is_same<Directed, bidirectionalS>::value));

typedef typename std::conditional<is_directed::value,
typedef typename std::conditional<is_directed,
bidirectional_tag, undirected_tag>::type
directed_category;

Expand Down
21 changes: 10 additions & 11 deletions include/boost/graph/detail/adjacency_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2225,8 +2225,8 @@ namespace boost {
{
static constexpr bool is_rand_access = detail::is_random_access<VertexListS>::value;
typedef typename has_property<EdgeProperty>::type has_edge_property;
typedef typename DirectedS::is_directed_t DirectedT;
typedef typename DirectedS::is_bidir_t BidirectionalT;
static constexpr bool DirectedT = DirectedS::is_directed;
static constexpr bool BidirectionalT = DirectedS::is_bidir;

struct config
{
Expand Down Expand Up @@ -2266,18 +2266,17 @@ namespace boost {
typedef typename container_gen<EdgeListS,
list_edge<vertex_descriptor, EdgeProperty> >::type EdgeContainer;

typedef typename std::conjunction<DirectedT,
typename std::negation<BidirectionalT>::type >::type on_edge_storage;
static constexpr bool on_edge_storage = DirectedT && !BidirectionalT;

typedef typename std::conditional<on_edge_storage::value,
typedef typename std::conditional<on_edge_storage,
std::size_t, typename EdgeContainer::size_type
>::type edges_size_type;

typedef typename EdgeContainer::iterator EdgeIter;

static constexpr bool is_edge_ra = detail::is_random_access<EdgeListS>::value;

typedef typename std::conditional<on_edge_storage::value,
typedef typename std::conditional<on_edge_storage,
stored_edge_property<vertex_descriptor, EdgeProperty>,
typename std::conditional<is_edge_ra,
stored_ra_edge_iter<vertex_descriptor, EdgeContainer, EdgeProperty>,
Expand Down Expand Up @@ -2330,7 +2329,7 @@ namespace boost {
typedef adj_list_edge_iterator<vertex_iterator, out_edge_iterator,
graph_type> DirectedEdgeIter;

typedef typename std::conditional<on_edge_storage::value,
typedef typename std::conditional<on_edge_storage,
DirectedEdgeIter, UndirectedEdgeIter>::type edge_iterator;

// stored_vertex and StoredVertexList
Expand Down Expand Up @@ -2365,9 +2364,9 @@ namespace boost {
VertexProperty m_property;
};
typedef typename std::conditional<is_rand_access,
typename std::conditional<BidirectionalT::value,
typename std::conditional<BidirectionalT,
bidir_rand_stored_vertex, rand_stored_vertex>::type,
typename std::conditional<BidirectionalT::value,
typename std::conditional<BidirectionalT,
bidir_seq_stored_vertex, seq_stored_vertex>::type
>::type StoredVertex;
struct stored_vertex : public StoredVertex {
Expand All @@ -2382,9 +2381,9 @@ namespace boost {
}; // end of config


typedef typename std::conditional<BidirectionalT::value,
typedef typename std::conditional<BidirectionalT,
bidirectional_graph_helper_with_property<config>,
typename std::conditional<DirectedT::value,
typename std::conditional<DirectedT,
directed_graph_helper<config>,
undirected_graph_helper<config>
>::type
Expand Down
11 changes: 2 additions & 9 deletions include/boost/graph/graph_selectors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,16 @@ namespace boost {
struct directedS {
static constexpr bool is_directed = true;
static constexpr bool is_bidir = false;

typedef std::true_type is_directed_t;
typedef std::false_type is_bidir_t;
};

struct undirectedS {
static constexpr bool is_directed = false;
static constexpr bool is_bidir = false;

typedef std::false_type is_directed_t;
typedef std::false_type is_bidir_t;
};

struct bidirectionalS {
static constexpr bool is_directed = true;
static constexpr bool is_bidir = true;

typedef std::true_type is_directed_t;
typedef std::true_type is_bidir_t;
};

} // namespace boost
Expand Down

0 comments on commit baacbb6

Please sign in to comment.