fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4. #include <boost/shared_ptr.hpp>
  5. #include <boost/flyweight.hpp>
  6.  
  7. using namespace boost;
  8. using namespace boost::flyweights;
  9. typedef flyweight<
  10. std::string,
  11. hashed_factory<
  12. boost::hash<std::string>,
  13. std::equal_to<std::string>,
  14. std::allocator<boost::mpl::_1> // here we get errors like C2065: 'key_value' : undeclared identifier
  15. >
  16. > customString;
  17.  
  18. typedef std::map<customString, customString> Map;
  19.  
  20. void pass_and_modify_data(boost::shared_ptr<Map> map) { /* TBI */ }
  21.  
  22. int main()
  23. {
  24. // boring part - load plugin... into something like boost::shared_ptr<plugin> my_plugin
  25. //intresting part - create map in main heap and make all its values and keys be forced to be allocated or reallocated in main heap
  26.  
  27. std::cout << std::endl << "Map allocator based memory management:" << std::endl;
  28. std::cin.get();
  29. {
  30. customString x;
  31. Map xxx;
  32. boost::shared_ptr<Map > a (new Map());
  33. pass_and_modify_data(a);
  34.  
  35. customString key1("hello"), key2("world");
  36.  
  37. std::cout << "modified data: " << (*a)[key1] << (*a)[key2] << std::endl;
  38. }
  39. std::cout << "removed data" << std::endl;
  40. std::cin.get();
  41.  
  42. }
  43.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/home/5FmZyt/cc61g3Fa.o: In function `global constructors keyed to _Z20pass_and_modify_dataN5boost10shared_ptrISt3mapINS_10flyweights9flyweightISsNS2_14hashed_factoryINS_4hashISsEESt8equal_toISsESaIN4mpl_3argILi1EEEELi0EEENS_9parameter5void_ESF_SF_SF_EESG_St4lessISG_ESaISt4pairIKSG_SG_EEEEE':
prog.cpp:(.text+0x130b): undefined reference to `pthread_mutexattr_init'
prog.cpp:(.text+0x131b): undefined reference to `pthread_mutexattr_settype'
prog.cpp:(.text+0x1333): undefined reference to `pthread_mutexattr_destroy'
/home/5FmZyt/cc61g3Fa.o: In function `boost::flyweights::static_holder_class<boost::flyweights::detail::flyweight_core<boost::flyweights::detail::default_value_policy<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<boost::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<mpl_::arg<1> >, 0>, boost::flyweights::simple_locking, boost::flyweights::static_holder>::holder_arg>::get()':
prog.cpp:(.text._ZN5boost10flyweights19static_holder_classINS0_6detail14flyweight_coreINS2_20default_value_policyISsEEN4mpl_2naENS0_10refcountedENS0_14hashed_factoryINS_4hashISsEESt8equal_toISsESaINS6_3argILi1EEEELi0EEENS0_14simple_lockingENS0_13static_holderEE10holder_argEE3getEv[boost::flyweights::static_holder_class<boost::flyweights::detail::flyweight_core<boost::flyweights::detail::default_value_policy<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<boost::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<mpl_::arg<1> >, 0>, boost::flyweights::simple_locking, boost::flyweights::static_holder>::holder_arg>::get()]+0x124): undefined reference to `pthread_mutexattr_init'
prog.cpp:(.text._ZN5boost10flyweights19static_holder_classINS0_6detail14flyweight_coreINS2_20default_value_policyISsEEN4mpl_2naENS0_10refcountedENS0_14hashed_factoryINS_4hashISsEESt8equal_toISsESaINS6_3argILi1EEEELi0EEENS0_14simple_lockingENS0_13static_holderEE10holder_argEE3getEv[boost::flyweights::static_holder_class<boost::flyweights::detail::flyweight_core<boost::flyweights::detail::default_value_policy<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<boost::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<mpl_::arg<1> >, 0>, boost::flyweights::simple_locking, boost::flyweights::static_holder>::holder_arg>::get()]+0x134): undefined reference to `pthread_mutexattr_settype'
prog.cpp:(.text._ZN5boost10flyweights19static_holder_classINS0_6detail14flyweight_coreINS2_20default_value_policyISsEEN4mpl_2naENS0_10refcountedENS0_14hashed_factoryINS_4hashISsEESt8equal_toISsESaINS6_3argILi1EEEELi0EEENS0_14simple_lockingENS0_13static_holderEE10holder_argEE3getEv[boost::flyweights::static_holder_class<boost::flyweights::detail::flyweight_core<boost::flyweights::detail::default_value_policy<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<boost::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<mpl_::arg<1> >, 0>, boost::flyweights::simple_locking, boost::flyweights::static_holder>::holder_arg>::get()]+0x14c): undefined reference to `pthread_mutexattr_destroy'
/home/5FmZyt/cc61g3Fa.o: In function `boost::flyweights::flyweight<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::flyweights::hashed_factory<boost::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<mpl_::arg<1> >, 0>, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::flyweight()':
prog.cpp:(.text._ZN5boost10flyweights9flyweightISsNS0_14hashed_factoryINS_4hashISsEESt8equal_toISsESaIN4mpl_3argILi1EEEELi0EEENS_9parameter5void_ESD_SD_SD_EC1Ev[boost::flyweights::flyweight<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::flyweights::hashed_factory<boost::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<mpl_::arg<1> >, 0>, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::flyweight()]+0x6ab): undefined reference to `pthread_mutexattr_init'
prog.cpp:(.text._ZN5boost10flyweights9flyweightISsNS0_14hashed_factoryINS_4hashISsEESt8equal_toISsESaIN4mpl_3argILi1EEEELi0EEENS_9parameter5void_ESD_SD_SD_EC1Ev[boost::flyweights::flyweight<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::flyweights::hashed_factory<boost::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<mpl_::arg<1> >, 0>, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::flyweight()]+0x6bb): undefined reference to `pthread_mutexattr_settype'
prog.cpp:(.text._ZN5boost10flyweights9flyweightISsNS0_14hashed_factoryINS_4hashISsEESt8equal_toISsESaIN4mpl_3argILi1EEEELi0EEENS_9parameter5void_ESD_SD_SD_EC1Ev[boost::flyweights::flyweight<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::flyweights::hashed_factory<boost::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<mpl_::arg<1> >, 0>, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::flyweight()]+0x6d3): undefined reference to `pthread_mutexattr_destroy'
collect2: ld returned 1 exit status
stdout
Standard output is empty