0

I have a file starting with following include but it gives the following below compiler error

error: reference to 'allocator' is ambiguous | typedef allocator void_allocator;

The file is not complete but Please note that The same file compile properly on g++ (Ubuntu 4.9.2-0ubuntu1~14.04) 4.9.2

What does this allocator ambiguous error mean?

#include <boost/interprocess/managed_shared_memory.hpp>
        #include <boost/interprocess/allocators/allocator.hpp>
        #include <boost/interprocess/containers/string.hpp>
        #include <iostream>
    #include <boost/unordered_map.hpp>     //boost::unordered_map
    #include <functional>                  //std::equal_to
    #include <boost/functional/hash.hpp>   //boost::hash


    using namespace boost::interprocess;
//Typedefs of allocators and containers
typedef managed_shared_memory::segment_manager                       segment_manager_t;
typedef allocator<void, segment_manager_t>                           void_allocator;
typedef allocator<char, segment_manager_t>                           char_allocator;
typedef basic_string<char, std::char_traits<char>, char_allocator>   char_string;
typedef allocator<int, segment_manager_t>                            int_allocator;
typedef allocator<float, segment_manager_t>                            float_allocator;
typedef float complex_data;
Sri Kant
  • 169
  • 1
  • 12
  • 3
    Try removing all occurrences of `using namespace ...` from your headers. You are probably bringing various `allocator` classes into the global namespace (possibly `std::allocator` and `boost::interprocess::allocator`). – DanielKO Aug 03 '15 at 07:30
  • Its a header file mix up. Thanks DanielKO – Sri Kant Aug 04 '15 at 16:52
  • @SriKant that's **not** a header file mix up. It's a namespace collision. And you **asked** for it by the [_using-directive_](http://en.cppreference.com/w/cpp/language/namespace#Using-directives) – sehe Aug 04 '15 at 21:52

0 Answers0