Re[4]: Abyx
От: Evgeny.Panasyuk Россия  
Дата: 16.04.14 10:18
Оценка: 18 (1) +1
Здравствуйте, niXman, Вы писали:

X>стандартная тоже принимает value_type, вот же.


Там примерно следующая ситуация:
#include <numeric>
#include <utility>
#include <string>
using namespace std;

void test(const pair<const int, string> &){} // #1
void test(const pair<int, string> &){} // #2
template<typename T> void test(T&&){} // #3

int main()
{
    test(make_pair(1, "1"));
}

В Boost — #1 и #2, конверсия возможна и в #1 и в #2, отсюда и is ambiguous.
А в std — #1 и #3.
Re[2]: 'std::map::insert()' vs 'boost::container::map::insert()'
От: Кодт Россия  
Дата: 16.04.14 10:51
Оценка: 16 (1)
Здравствуйте, Evgeny.Panasyuk, Вы писали:

EP>offtopic: а как выделить код прям в тексте? (ccode переходит на новую строку. помню был способ для выделения прям в строке)

Ты имеешь в виду [ tt ]...[ /tt ] ?
Перекуём баги на фичи!
Re: 'std::map::insert()' vs 'boost::container::map::insert()'
От: zaufi Земля  
Дата: 16.04.14 10:21
Оценка: +1
Здравствуйте, niXman, Вы писали:

X>приветствую!


X>есть такой код, который успешно компилируется и работает:

X>
X>std::map<int, std::string> map;
X>map.insert(std::make_pair(1, "1"));
X>


<offtopic>
если С++11 доступен, нахрена вообще в таком случае использовать insert()? есть же более эффективный emplace()!

std::map<int, std::string> map;
map.empalce(1, "1");

</offtopic>
'std::map::insert()' vs 'boost::container::map::insert()'
От: niXman Ниоткуда https://github.com/niXman
Дата: 16.04.14 09:22
Оценка:
приветствую!

есть такой код, который успешно компилируется и работает:
std::map<int, std::string> map;
map.insert(std::make_pair(1, "1"));

но, если в этом коде заменить 'std::map<>' на 'boost::container::map<>', — то поучим приблизительно такие ошибки:

../include/boost_cont_map.hpp:61:35: error: call of overloaded 'insert(std::pair<int, const char*>)' is ambiguous
map.insert(std::make_pair(1, "1"));
^
../include/boost_cont_map.hpp:61:35: note: candidates are:
In file included from ../../../include/yas/serializers/binary/boost/boost_container_map_serializers.hpp:40:0,
from ../../../include/yas/serializers/boost_types_serializers.hpp:96,
from ../main.cpp:52:
/usr/local/include/boost/container/map.hpp:470:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(const value_type&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::value_type = std::pair<const int, std::basic_string<char> >]
std::pair<iterator,bool> insert(const value_type& x)
^
/usr/local/include/boost/container/map.hpp:481:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(const nonconst_value_type&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::nonconst_value_type = std::pair<int, std::basic_string<char> >]
std::pair<iterator,bool> insert(const nonconst_value_type& x)
^
/usr/local/include/boost/container/map.hpp:492:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(boost::container::map<Key, T, Compare, Allocator>::nonconst_value_type&&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::nonconst_value_type = std::pair<int, std::basic_string<char> >]
std::pair<iterator,bool> insert(BOOST_RV_REF(nonconst_value_type) x)
^
/usr/local/include/boost/container/map.hpp:503:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(boost::container::map<Key, T, Compare, Allocator>::movable_value_type&&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::movable_value_type = boost::container::container_detail::pair<int, std::basic_string<char> >]
std::pair<iterator,bool> insert(BOOST_RV_REF(movable_value_type) x)
^
/usr/local/include/boost/container/map.hpp:514:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(boost::container::map<Key, T, Compare, Allocator>::value_type&&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::value_type = std::pair<const int, std::basic_string<char> >]
std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x)
^
In file included from ../main.cpp:85:0:
../include/boost_cont_map.hpp:62:35: error: call of overloaded 'insert(std::pair<int, const char*>)' is ambiguous
map.insert(std::make_pair(2, "2"));
^
../include/boost_cont_map.hpp:62:35: note: candidates are:
In file included from ../../../include/yas/serializers/binary/boost/boost_container_map_serializers.hpp:40:0,
from ../../../include/yas/serializers/boost_types_serializers.hpp:96,
from ../main.cpp:52:
/usr/local/include/boost/container/map.hpp:470:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(const value_type&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::value_type = std::pair<const int, std::basic_string<char> >]
std::pair<iterator,bool> insert(const value_type& x)
^
/usr/local/include/boost/container/map.hpp:481:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(const nonconst_value_type&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::nonconst_value_type = std::pair<int, std::basic_string<char> >]
std::pair<iterator,bool> insert(const nonconst_value_type& x)
^
/usr/local/include/boost/container/map.hpp:492:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(boost::container::map<Key, T, Compare, Allocator>::nonconst_value_type&&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::nonconst_value_type = std::pair<int, std::basic_string<char> >]
std::pair<iterator,bool> insert(BOOST_RV_REF(nonconst_value_type) x)
^
/usr/local/include/boost/container/map.hpp:503:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(boost::container::map<Key, T, Compare, Allocator>::movable_value_type&&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::movable_value_type = boost::container::container_detail::pair<int, std::basic_string<char> >]
std::pair<iterator,bool> insert(BOOST_RV_REF(movable_value_type) x)
^
/usr/local/include/boost/container/map.hpp:514:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(boost::container::map<Key, T, Compare, Allocator>::value_type&&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::value_type = std::pair<const int, std::basic_string<char> >]
std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x)
^
In file included from ../main.cpp:85:0:
../include/boost_cont_map.hpp:63:35: error: call of overloaded 'insert(std::pair<int, const char*>)' is ambiguous
map.insert(std::make_pair(3, "3"));
^
../include/boost_cont_map.hpp:63:35: note: candidates are:
In file included from ../../../include/yas/serializers/binary/boost/boost_container_map_serializers.hpp:40:0,
from ../../../include/yas/serializers/boost_types_serializers.hpp:96,
from ../main.cpp:52:
/usr/local/include/boost/container/map.hpp:470:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(const value_type&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::value_type = std::pair<const int, std::basic_string<char> >]
std::pair<iterator,bool> insert(const value_type& x)
^
/usr/local/include/boost/container/map.hpp:481:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(const nonconst_value_type&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::nonconst_value_type = std::pair<int, std::basic_string<char> >]
std::pair<iterator,bool> insert(const nonconst_value_type& x)
^
/usr/local/include/boost/container/map.hpp:492:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(boost::container::map<Key, T, Compare, Allocator>::nonconst_value_type&&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::nonconst_value_type = std::pair<int, std::basic_string<char> >]
std::pair<iterator,bool> insert(BOOST_RV_REF(nonconst_value_type) x)
^
/usr/local/include/boost/container/map.hpp:503:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(boost::container::map<Key, T, Compare, Allocator>::movable_value_type&&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::movable_value_type = boost::container::container_detail::pair<int, std::basic_string<char> >]
std::pair<iterator,bool> insert(BOOST_RV_REF(movable_value_type) x)
^
/usr/local/include/boost/container/map.hpp:514:29: note: std::pair<typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator, bool> boost::container::map<Key, T, Compare, Allocator>::insert(boost::container::map<Key, T, Compare, Allocator>::value_type&&) [with Key = int; T = std::basic_string<char>; Compare = std::less<int>; Allocator = std::allocator<std::pair<const int, std::basic_string<char> > >; typename boost::container::container_detail::rbtree<Key, std::pair<const Key, T>, boost::container::container_detail::select1st<std::pair<const Key, T> >, Compare, Allocator>::iterator = boost::container::container_detail::iterator<boost::intrusive::tree_iterator<boost::intrusive::bhtraits<boost::container::container_detail::rbtree_node<std::pair<const int, std::basic_string<char> >, void*>, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)0u, boost::intrusive::default_tag, 3u>, false>, false>; boost::container::map<Key, T, Compare, Allocator>::value_type = std::pair<const int, std::basic_string<char> >]
std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x)

(так как тут спойлер создавать? я же видел на этом форуме спойлеры.)

проблема решается таким способом:
map.insert(std::make_pair<int, std::string>(1, "1"));

но мне интересно, почему в случае использования 'std::map<>' этой проблемы не существует вовсе?
сам понять не смог...

благодарен!
пачка бумаги А4 стОит 2000 р, в ней 500 листов. получается, лист обычной бумаги стОит дороже имперского рубля =)
Re: 'std::map::insert()' vs 'boost::container::map::insert()'
От: niXman Ниоткуда https://github.com/niXman
Дата: 16.04.14 09:31
Оценка:
собственно хидер 'boost::container::map<>'.
пачка бумаги А4 стОит 2000 р, в ней 500 листов. получается, лист обычной бумаги стОит дороже имперского рубля =)
Re: 'std::map::insert()' vs 'boost::container::map::insert()'
От: Lom  
Дата: 16.04.14 09:44
Оценка:
Здравствуйте, niXman, Вы писали:

X>приветствую!


X>есть такой код, который успешно компилируется и работает:

X>
X>std::map<int, std::string> map;
X>map.insert(std::make_pair(1, "1"));
X>

X>но, если в этом коде заменить 'std::map<>' на 'boost::container::map<>', — то поучим приблизительно такие ошибки:
X>благодарен!

Почему бы не использовать value_type? typedef на контейнер, а потом MYContainerType::value_type(Key, Value)
Re[2]: 'std::map::insert()' vs 'boost::container::map::insert()'
От: niXman Ниоткуда https://github.com/niXman
Дата: 16.04.14 09:56
Оценка:
Здравствуйте, Lom, Вы писали:

Lom>Почему бы не использовать value_type? typedef на контейнер, а потом MYContainerType::value_type(Key, Value)

да, можно и так решить. но вопрос-то в другом.
пачка бумаги А4 стОит 2000 р, в ней 500 листов. получается, лист обычной бумаги стОит дороже имперского рубля =)
Re[2]: Abyx
От: Abyx Россия  
Дата: 16.04.14 09:58
Оценка:
Здравствуйте, niXman, Вы писали:

X>собственно хидер 'boost::container::map<>'.


бустовская принимает только value_type,
а стандартная — любой тип P у которого std::is_constructible<value_type, P&&>::value == true
In Zen We Trust
Re[3]: Abyx
От: Evgeny.Panasyuk Россия  
Дата: 16.04.14 10:09
Оценка:
Здравствуйте, Abyx, Вы писали:

X>>собственно хидер 'boost::container::map<>'.

A>бустовская принимает только value_type,
A>а стандартная — любой тип P у которого std::is_constructible<value_type, P&&>::value == true

Не поэтому. В Boost есть pair<const int, std::string> и pair<int, std::string> (но нет T&&) — конверсия может пройти и туда и туда, поэтому компилятор и говорит is ambiguous.
Re[3]: Abyx
От: niXman Ниоткуда https://github.com/niXman
Дата: 16.04.14 10:11
Оценка:
Здравствуйте, Abyx, Вы писали:

стандартная тоже принимает value_type, вот же.
пачка бумаги А4 стОит 2000 р, в ней 500 листов. получается, лист обычной бумаги стОит дороже имперского рубля =)
Re: 'std::map::insert()' vs 'boost::container::map::insert()'
От: Evgeny.Panasyuk Россия  
Дата: 16.04.14 10:13
Оценка:
Здравствуйте, niXman, Вы писали:

X>(так как тут спойлер создавать? я же видел на этом форуме спойлеры.)


[cut=name][/cut]

offtopic: а как выделить код прям в тексте? (ccode переходит на новую строку. помню был способ для выделения прям в строке)

X>проблема решается таким способом:

X>
X>map.insert(std::make_pair<int, std::string>(1, "1"));
X>

В этом случае и make_pair не нужен, уж лучше тогда просто pair — как минимум короче.
Re[5]: Abyx
От: niXman Ниоткуда https://github.com/niXman
Дата: 16.04.14 10:25
Оценка:
Здравствуйте, Evgeny.Panasyuk, Вы писали:

EP>В Boost — #1 и #2, конверсия возможна и в #1 и в #2, отсюда и is ambiguous.

EP>А в std — #1 и #3.
теперь понял.

спасибо, вопрос закрыт!
пачка бумаги А4 стОит 2000 р, в ней 500 листов. получается, лист обычной бумаги стОит дороже имперского рубля =)
Re[2]: 'std::map::insert()' vs 'boost::container::map::insert()'
От: niXman Ниоткуда https://github.com/niXman
Дата: 16.04.14 10:26
Оценка:
Здравствуйте, zaufi, Вы писали:

Z>если С++11 доступен, нахрена вообще в таком случае использовать insert()? есть же более эффективный emplace()!

да, но код писался раньше одинадцатого стандарта. и да, 'emplace()' решает проблему.
пачка бумаги А4 стОит 2000 р, в ней 500 листов. получается, лист обычной бумаги стОит дороже имперского рубля =)
Re[3]: 'std::map::insert()' vs 'boost::container::map::insert()'
От: Evgeny.Panasyuk Россия  
Дата: 16.04.14 10:55
Оценка:
Здравствуйте, Кодт, Вы писали:

EP>>offtopic: а как выделить код прям в тексте? (ccode переходит на новую строку. помню был способ для выделения прям в строке)

К>Ты имеешь в виду [ tt ]...[ /tt ] ?

Да, спасибо.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.