| 1 | /*
|
|---|
| 2 | * File: container_traits_issue.cpp
|
|---|
| 3 | * Author: erdem
|
|---|
| 4 | *
|
|---|
| 5 | * Created on September 8, 2016, 3:09 PM
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #include <deque>
|
|---|
| 9 |
|
|---|
| 10 | #include <boost/pending/container_traits.hpp>
|
|---|
| 11 |
|
|---|
| 12 | namespace boost {
|
|---|
| 13 | // If contents of the graph_details namespace below are put inside
|
|---|
| 14 | // boost/pending/graph_traits.hpp, compile succeeds,
|
|---|
| 15 | namespace graph_detail
|
|---|
| 16 | {
|
|---|
| 17 | struct deque_tag :
|
|---|
| 18 | virtual public random_access_container_tag,
|
|---|
| 19 | virtual public back_insertion_sequence_tag { };
|
|---|
| 20 |
|
|---|
| 21 | template <class T, class Alloc>
|
|---|
| 22 | deque_tag container_category(const std::deque<T,Alloc>&) {
|
|---|
| 23 | return deque_tag();
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | template <class T, class Alloc>
|
|---|
| 27 | unstable_tag iterator_stability(const std::deque<T,Alloc>&) {
|
|---|
| 28 | return unstable_tag();
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | template <class T, class Alloc>
|
|---|
| 32 | struct container_traits< std::deque<T,Alloc> > {
|
|---|
| 33 | typedef deque_tag category;
|
|---|
| 34 | typedef unstable_tag iterator_stability;
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 | } //ns: graph_detail
|
|---|
| 38 | } // ns: boost
|
|---|
| 39 |
|
|---|
| 40 | #include <boost/graph/adjacency_list.hpp>
|
|---|
| 41 |
|
|---|
| 42 | namespace boost {
|
|---|
| 43 | struct dequeS;
|
|---|
| 44 |
|
|---|
| 45 | template <class T>
|
|---|
| 46 | struct container_gen<dequeS, T> {
|
|---|
| 47 | typedef std::deque<T> type;
|
|---|
| 48 | };
|
|---|
| 49 |
|
|---|
| 50 | template <>
|
|---|
| 51 | struct parallel_edge_traits<dequeS> {
|
|---|
| 52 | typedef allow_parallel_edge_tag type;
|
|---|
| 53 | };
|
|---|
| 54 |
|
|---|
| 55 | namespace detail {
|
|---|
| 56 | template <>
|
|---|
| 57 | struct is_random_access<dequeS> {
|
|---|
| 58 | enum { value = true };
|
|---|
| 59 | typedef mpl::true_ type;
|
|---|
| 60 | };
|
|---|
| 61 | }
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | int main(int argc, char** argv) {
|
|---|
| 65 | using namespace boost;
|
|---|
| 66 | typedef adjacency_list<dequeS, dequeS, undirectedS> graph_t;
|
|---|
| 67 | graph_t g(2);
|
|---|
| 68 | boost::add_edge(0ul, 1ul, g);
|
|---|
| 69 | return 0;
|
|---|
| 70 | }
|
|---|