Opened 10 years ago

Closed 10 years ago

#7367 closed Bugs (duplicate)

Ambiguity with nested list_of on C++11/C++0x compilers

Reported by: zadirion@… Owned by: Thorsten Ottosen
Milestone: To Be Determined Component: assign
Version: Boost 1.52.0 Severity: Regression
Keywords: Cc: victor.ciura@…

Description

The following code compiles in VS2010, however when compiled with VS2012 or GCC 4.7.1 it no longer compiles.

#include "stdafx.h"
#include <string>
#include <vector>
#include <boost/assign.hpp>

using namespace std;

typedef wstring IssueInfo;

typedef vector<IssueInfo> IssuesAndFixes;

typedef pair<wstring, IssuesAndFixes> IssueCategoryEntry;

typedef vector<IssueCategoryEntry> IssuesAndFixesMap;

extern const IssuesAndFixesMap kIssuesAndFixes;

IssuesAndFixes dummy;

const IssuesAndFixesMap kIssuesAndFixes =
  boost::assign::list_of<IssueCategoryEntry>
  (
    wstring(), boost::assign::list_of<IssueInfo>
    (
    )
  );

int main()
{
  return 0;
}

Error in GCC is:

Compilation finished with errors:
In file included from include/c++/4.7.1/bits/stl_algobase.h:65:0,
                 from include/c++/4.7.1/bits/char_traits.h:41,
                 from include/c++/4.7.1/string:42,
                 from source.cpp:1:
include/c++/4.7.1/bits/stl_pair.h: In instantiation of 'constexpr std::pair<_T1, _T2>::pair(const _T1&, _U2&&) [with _U2 = const boost::assign_detail::generic_list<std::basic_string<wchar_t> >&; <template-parameter-2-2> = void; _T1 = std::basic_string<wchar_t>; _T2 = std::vector<std::basic_string<wchar_t> >]':
boost/preprocessor/iteration/detail/local.hpp:37:1:   required from 'boost::assign_detail::generic_list<T>& boost::assign_detail::generic_list<T>::operator()(const U&, const U0&) [with U = std::basic_string<wchar_t>; U0 = boost::assign_detail::generic_list<std::basic_string<wchar_t> >; T = std::pair<std::basic_string<wchar_t>, std::vector<std::basic_string<wchar_t> > >; boost::assign_detail::generic_list<T> = boost::assign_detail::generic_list<std::pair<std::basic_string<wchar_t>, std::vector<std::basic_string<wchar_t> > > >]'
boost/preprocessor/iteration/detail/local.hpp:37:1:   required from 'boost::assign_detail::generic_list<T> boost::assign::list_of(const U&, const U0&) [with T = std::pair<std::basic_string<wchar_t>, std::vector<std::basic_string<wchar_t> > >; U = std::basic_string<wchar_t>; U0 = boost::assign_detail::generic_list<std::basic_string<wchar_t> >]'
source.cpp:25:3:   required from here
include/c++/4.7.1/bits/stl_pair.h:137:45: error: call of overloaded 'vector(const boost::assign_detail::generic_list<std::basic_string<wchar_t> >&)' is ambiguous
include/c++/4.7.1/bits/stl_pair.h:137:45: note: candidates are:
In file included from include/c++/4.7.1/vector:65:0,
                 from source.cpp:2:
include/c++/4.7.1/bits/stl_vector.h:361:7: note: std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::basic_string<wchar_t>; _Alloc = std::allocator<std::basic_string<wchar_t> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::basic_string<wchar_t> >]
include/c++/4.7.1/bits/stl_vector.h:324:7: note: std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::basic_string<wchar_t>; _Alloc = std::allocator<std::basic_string<wchar_t> >; std::vector<_Tp, _Alloc> = std::vector<std::basic_string<wchar_t> >]
include/c++/4.7.1/bits/stl_vector.h:307:7: note: std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::basic_string<wchar_t>; _Alloc = std::allocator<std::basic_string<wchar_t> >; std::vector<_Tp, _Alloc> = std::vector<std::basic_string<wchar_t> >]
include/c++/4.7.1/bits/stl_vector.h:266:7: note: std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::basic_string<wchar_t>; _Alloc = std::allocator<std::basic_string<wchar_t> >; std::vector<_Tp, _Alloc>::size_type = unsigned int]
include/c++/4.7.1/bits/stl_vector.h:254:7: note: std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::basic_string<wchar_t>; _Alloc = std::allocator<std::basic_string<wchar_t> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::basic_string<wchar_t> >]


Adding a to_container(dummy) call on the second list_of fixes the issue though.

Example: liveworkspace.org/code/38e5fafed72adf0730ad71ebb599c97e

Change History (1)

comment:1 by Eric Niebler, 10 years ago

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.