diff --git a/config.lib b/config.lib index c08b122684..aabfdd1d80 100644 --- a/config.lib +++ b/config.lib @@ -1413,6 +1413,11 @@ make_compiler_cflags() { flags="$flags -Wno-free-nonheap-object" fi + if [ $cc_version -ge 49 ]; then + # Enable use of C++11 custom allocators + CFLAGS="$CFLAGS -DCUSTOM_ALLOCATOR" + fi + if [ "$enable_lto" != "0" ]; then # GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}' has_lto=`$1 -dumpspecs | grep '\%{flto'` diff --git a/src/linkgraph/mcf.cpp b/src/linkgraph/mcf.cpp index 2d44c79ba8..5546542316 100644 --- a/src/linkgraph/mcf.cpp +++ b/src/linkgraph/mcf.cpp @@ -261,6 +261,7 @@ bool CapacityAnnotation::IsBetter(const CapacityAnnotation *base, uint cap, } } +#ifdef CUSTOM_ALLOCATOR /** * Storage for AnnoSetAllocator instances */ @@ -334,6 +335,7 @@ struct AnnoSetAllocator { store.last_freed = p; } }; +#endif /** * Annotation wrapper class which also stores an iterator to the AnnoSet node which points to this annotation @@ -341,7 +343,12 @@ struct AnnoSetAllocator { */ template struct AnnosWrapper : public Tannotation { +#ifdef CUSTOM_ALLOCATOR typename std::set, typename Tannotation::Comparator, AnnoSetAllocator > >::iterator self_iter; +#else + typename std::set, typename Tannotation::Comparator>::iterator self_iter; +#endif + AnnosWrapper(NodeID n, bool source = false) : Tannotation(n, source) {} }; @@ -358,11 +365,16 @@ struct AnnosWrapper : public Tannotation { template void MultiCommodityFlow::Dijkstra(NodeID source_node, PathVector &paths) { +#ifdef CUSTOM_ALLOCATOR typedef std::set, typename Tannotation::Comparator, AnnoSetAllocator > > AnnoSet; - Tedge_iterator iter(this->job); - uint size = this->job.Size(); AnnoSetAllocatorStore annos_store; AnnoSet annos = AnnoSet(typename Tannotation::Comparator(), AnnoSetAllocator(annos_store)); +#else + typedef std::set, typename Tannotation::Comparator> AnnoSet; + AnnoSet annos = AnnoSet(typename Tannotation::Comparator()); +#endif + Tedge_iterator iter(this->job); + uint size = this->job.Size(); paths.resize(size, NULL); for (NodeID node = 0; node < size; ++node) { AnnosWrapper *anno = new AnnosWrapper(node, node == source_node);