Created
October 28, 2015 21:17
-
-
Save jacquelinekay/5cb6247267f3ed947fc5 to your computer and use it in GitHub Desktop.
bug in apple clang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <memory> | |
#include <vector> | |
// Example allocator, doesn't do anything but implements std::allocator_traits | |
template<typename T> | |
struct null_allocator { | |
using value_type = T; | |
using size_type = std::size_t; | |
using pointer = T *; | |
using const_pointer = const pointer; | |
//using difference_type = typename std::pointer_traits<pointer>::difference_type; | |
using reference = T &; | |
using const_reference = const T &; | |
null_allocator() {} | |
template<typename U> | |
null_allocator(const null_allocator<U>&) {} | |
T* allocate(std::size_t size) { | |
(void) size; | |
return nullptr; | |
} | |
void deallocate(T* ptr, std::size_t size) { | |
(void) ptr; | |
(void) size; | |
} | |
template<typename U> | |
struct rebind | |
{ | |
typedef null_allocator<U> other; | |
}; | |
}; | |
int main(int argc, char** argv) { | |
std::vector<void*, null_allocator<void*>> vec; | |
void * args; | |
vec.push_back(args); | |
vec.erase(vec.begin()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment