Skip to content

Compile error using VS2010 #399

@Virtual-X

Description

@Virtual-X

Environment:
cpp-netlib 0.11.0
boost 1.55.0
VS2010, x64, Windows 7

Including cpp-netlib/include/boost/network/protocol/http/client.hpp in the compilation produce the following errors:

[...]\boost\include\boost/range/iterator_range_core.hpp(58): error C2440: 'static_cast' : cannot convert from 'std::_Tree_const_iterator<_Mytree>' to 'std::_Tree_const_iterator<_Mytree>'
          with
          [
              _Mytree=std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>
          ]
          and
          [
              _Mytree=std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::network::http::tags::http,boost::network::http::tags::client>,boost::network::http::tags::simple>,boost::network::tags::sync>,boost::network::tags::udp>,boost::network::tags::default_string>>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>
          ]
          No constructor could take the source type, or constructor overload resolution was ambiguous
          [...]\boost\include\boost/range/iterator_range_core.hpp(189) : see reference to function template instantiation 'IteratorT boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_begin<const Range>(ForwardRange &)' being compiled
          with
          [
              IteratorT=std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::network::http::tags::http,boost::network::http::tags::client>,boost::network::http::tags::simple>,boost::network::tags::sync>,boost::network::tags::udp>,boost::network::tags::default_string>>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,
              Range=std::pair<std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>>,
              ForwardRange=std::pair<std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>>
          ]
          [...]\cpp-netlib\include\boost/network/protocol/http/message/wrappers/headers.hpp(42) : see reference to function template instantiation 'boost::iterator_range<IteratorT>::iterator_range<std::pair<_Ty1,_Ty2>>(const Range &)' being compiled
          with
          [
              IteratorT=std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::network::http::tags::http,boost::network::http::tags::client>,boost::network::http::tags::simple>,boost::network::tags::sync>,boost::network::tags::udp>,boost::network::tags::default_string>>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,
              _Ty1=std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,
              _Ty2=std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,
              Range=std::pair<std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>>
          ]
          [...]\cpp-netlib\include\boost/network/protocol/http/message/wrappers/headers.hpp(41) : while compiling class template member function 'boost::iterator_range<IteratorT> boost::network::http::impl::request_headers_wrapper<Tag>::operator [](const std::basic_string<_Elem,_Traits,_Ax> &) const'
          with
          [
              IteratorT=std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::network::http::tags::http,boost::network::http::tags::client>,boost::network::http::tags::simple>,boost::network::tags::sync>,boost::network::tags::udp>,boost::network::tags::default_string>>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,
              Tag=boost::network::http::tags::http_async_8bit_udp_resolve,
              _Elem=char,
              _Traits=std::char_traits<char>,
              _Ax=std::allocator<char>
          ]
          [...]\cpp-netlib\include\boost/network/protocol/http/client/facade.hpp(69) : see reference to class template instantiation 'boost::network::http::impl::request_headers_wrapper<Tag>' being compiled
          with
          [
              Tag=boost::network::http::tags::http_async_8bit_udp_resolve
          ]
          [...]\cpp-netlib\include\boost/network/protocol/http/client/facade.hpp(61) : while compiling class template member function 'boost::network::http::basic_response<Tag> boost::network::http::basic_client_facade<Tag,version_major,version_minor>::post(boost::network::http::basic_request<Tag>,const std::basic_string<_Elem,_Traits,_Ax> &,const std::basic_string<_Elem,_Traits,_Ax> &,boost::network::http::basic_client_facade<Tag,version_major,version_minor>::body_callback_function_type,boost::function<Signature>)'
          with
          [
              Tag=boost::network::http::tags::http_async_8bit_udp_resolve,
              version_major=1,
              version_minor=1,
              _Elem=char,
              _Traits=std::char_traits<char>,
              _Ax=std::allocator<char>,
              Signature=bool (std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)
          ]
          [...]\cpp-netlib\include\boost/network/protocol/http/client.hpp(35) : see reference to class template instantiation 'boost::network::http::basic_client_facade<Tag,version_major,version_minor>' being compiled
          with
          [
              Tag=boost::network::http::tags::http_async_8bit_udp_resolve,
              version_major=1,
              version_minor=1
          ]
          D:\Data\i.beati\HEAD\bitplane\libs\common/utils/bpNetLibClient.h(51) : see reference to class template instantiation 'boost::network::http::basic_client<Tag,version_major,version_minor>' being compiled
          with
          [
              Tag=boost::network::http::tags::http_async_8bit_udp_resolve,
              version_major=1,
              version_minor=1
          ]
[...]\boost\include\boost/range/iterator_range_core.hpp(64): error C2440: 'static_cast' : cannot convert from 'std::_Tree_const_iterator<_Mytree>' to 'std::_Tree_const_iterator<_Mytree>'
          with
          [
              _Mytree=std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>
          ]
          and
          [
              _Mytree=std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::network::http::tags::http,boost::network::http::tags::client>,boost::network::http::tags::simple>,boost::network::tags::sync>,boost::network::tags::udp>,boost::network::tags::default_string>>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>
          ]
          No constructor could take the source type, or constructor overload resolution was ambiguous
          [...]\boost\include\boost/range/iterator_range_core.hpp(189) : see reference to function template instantiation 'IteratorT boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_end<const Range>(ForwardRange &)' being compiled
          with
          [
              IteratorT=std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::mpl::inherit2<boost::network::http::tags::http,boost::network::http::tags::client>,boost::network::http::tags::simple>,boost::network::tags::sync>,boost::network::tags::udp>,boost::network::tags::default_string>>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,
              Range=std::pair<std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>>,
              ForwardRange=std::pair<std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>,std::_Tree_const_iterator<std::_Tree_val<std::_Tmap_traits<boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::string<boost::network::http::tags::http_default_8bit_tcp_resolve>::type,boost::network::impl::headers_container_impl<boost::network::http::tags::http_async_8bit_udp_resolve>::is_less_ignore_case_impl,std::allocator<std::pair<const bpString,bpString>>,true>>>>
          ]

In practice, it rejects a conversion from A<B<T1>::is_less_ignore_case> to A<B<T2>::is_less_ignore_case>.

The problem can be fixed ensuring that there is only one definition of is_less_ignore_case, not nesting it into a template struct:

// Code from cpp-netlib/include/boost/network/protocol/http/traits/impl/headers_container.ipp
// [...]

namespace boost { namespace network { namespace impl {

    // Moving implementation from original
    // message_traits implementation by
    // Atomic Labs, Inc.
    // --
    // returns true if str1 < str2 (ignoring case)
    struct is_less_ignore_case_impl {
        inline bool operator() (
                string<http::tags::http_default_8bit_tcp_resolve>::type const & str1, 
                string<http::tags::http_default_8bit_tcp_resolve>::type const & str2) const {
            return to_lower_copy(str1) < to_lower_copy(str2);
        };
    };

    template <class Tag>
    struct headers_container_impl<Tag, typename enable_if<typename Tag::is_client>::type> {

        typedef is_less_ignore_case_impl is_less_ignore_case;

        typedef std::multimap<
            string<http::tags::http_default_8bit_tcp_resolve>::type,
            string<http::tags::http_default_8bit_tcp_resolve>::type,
            is_less_ignore_case> type;
    };

// [...]

I wonder if you want to include that change in the official release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions