The code
#include <memory>
#include <thread>
#include <chrono>
#include <atomic>
#include <iostream>
#include <map>
using namespace std;
static shared_ptr<multimap<string,int> > m1;
//static atomic<shared_ptr<multimap<string,int> > > m3;
int main()
{
multimap<string,int> m2;
m2.insert(make_pair("1",1));
//m3.store(std::make_shared<multimap<string,int> >(m2),std::memory_order_relaxed);
atomic_store(&m1, std::make_shared<multimap<string,int> >(m2));
}
works fine with gcc -dumpversion = 4.2.1 on mac, on Linux it is 4.8.5 it won't even compile, after changing it into commented out lines, syntax compilation failure goes away, but generates
/tmp/ccM6frcE.o: In function `std::atomic<std::shared_ptr<std::multimap<std::string, int, std::less<std::string>, std::allocator<std::pair<std::string const, int> > > > >::store(std::shared_ptr<std::multimap<std::string, int, std::less<std::string>, std::allocator<std::pair<std::string const, int> > > >, std::memory_order)':
tt.cpp:(.text._ZNSt6atomicISt10shared_ptrISt8multimapISsiSt4lessISsESaISt4pairIKSsiEEEEE5storeES9_St12memory_order[_ZNSt6atomicISt10shared_ptrISt8multimapISsiSt4lessISsESaISt4pairIKSsiEEEEE5storeES9_St12memory_order]+0x3a): undefined reference to `__atomic_store_16'
collect2: error: ld returned 1 exit status
is there any unresolved symbol/function problem?
compiling it like this on Linux
g++ --std=c++11 tt.cpp