1

最基本的最小示例:

#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/bzip2.hpp>  
int main() {
  boost::iostreams::filtering_istream in;
  in.push(boost::iostreams::bzip2_compressor());
  return 0;
}

在我的机器上编译得很好:

g++ -lboost_iostreams  simple.cpp 

但是当 c++0x 包含在以下任一实例中时失败:

g++ -lboost_iostreams  simple.cpp -std=c++0x
g++ -lboost_iostreams  simple.cpp -std=gnu++0x

疯狂的长错误消息如下。代码中的什么导致c++0x失败?如何解决这个问题?我已经运行了这三台机器,每台都有不同的配置——它在两台机器上都失败了,但在一个普通的 Ubuntu 安装上运行正常。

In file included from /usr/local/include/boost/iostreams/traits.hpp:31:0,
                 from /usr/local/include/boost/iostreams/pipeline.hpp:18,
                 from /usr/local/include/boost/iostreams/detail/push.hpp:22,
                 from /usr/local/include/boost/iostreams/filtering_stream.hpp:19,
                 from simple.cpp:1:
/usr/local/include/boost/iostreams/detail/wrap_unwrap.hpp: In instantiation of ‘T boost::iostreams::detail::wrap(const T&, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’:
/usr/local/include/boost/iostreams/stream_buffer.hpp:94:5:   required from ‘boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::stream_buffer(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:257:60:   required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:216:1:   required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
/usr/local/include/boost/iostreams/chain.hpp:496:7:   required from ‘void boost::iostreams::detail::chain_client<Chain>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:484:1:   required from ‘void boost::iostreams::detail::chain_client<Chain>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
simple.cpp:6:47:   required from here
/usr/local/include/boost/iostreams/detail/wrap_unwrap.hpp:53:14: error: use of deleted function ‘boost::iostreams::basic_bzip2_compressor<>::basic_bzip2_compressor(const boost::iostreams::basic_bzip2_compressor<>&)’
In file included from simple.cpp:2:0:
/usr/local/include/boost/iostreams/filter/bzip2.hpp:239:8: note: ‘boost::iostreams::basic_bzip2_compressor<>::basic_bzip2_compressor(const boost::iostreams::basic_bzip2_compressor<>&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/local/include/boost/iostreams/filter/bzip2.hpp:239:8: error: use of deleted function ‘boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::symmetric_filter(const boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >&)’
In file included from /usr/local/include/boost/iostreams/filter/bzip2.hpp:29:0,
                 from simple.cpp:2:
/usr/local/include/boost/iostreams/filter/symmetric.hpp:72:7: note: ‘boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::symmetric_filter(const boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/local/include/boost/iostreams/filter/symmetric.hpp:72:7: error: use of deleted function ‘boost::shared_ptr<boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>::shared_ptr(const boost::shared_ptr<boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>&)’
In file included from /usr/local/include/boost/shared_ptr.hpp:17:0,
                 from /usr/local/include/boost/iostreams/chain.hpp:37,
                 from /usr/local/include/boost/iostreams/filtering_streambuf.hpp:17,
                 from /usr/local/include/boost/iostreams/filtering_stream.hpp:22,
                 from simple.cpp:1:
/usr/local/include/boost/smart_ptr/shared_ptr.hpp:168:25: note: ‘boost::shared_ptr<boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>::shared_ptr(const boost::shared_ptr<boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>&)’ is implicitly declared as deleted because ‘boost::shared_ptr<boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>’ declares a move constructor or move assignment operator
In file included from /usr/local/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:23:0,
                 from /usr/local/include/boost/iostreams/stream_buffer.hpp:22,
                 from /usr/local/include/boost/iostreams/chain.hpp:35,
                 from /usr/local/include/boost/iostreams/filtering_streambuf.hpp:17,
                 from /usr/local/include/boost/iostreams/filtering_stream.hpp:22,
                 from simple.cpp:1:
/usr/local/include/boost/iostreams/detail/adapter/concept_adapter.hpp: In instantiation of ‘boost::iostreams::detail::concept_adapter<T>::concept_adapter(const T&) [with T = boost::iostreams::basic_bzip2_compressor<>]’:
/usr/local/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:187:5:   required from ‘void boost::iostreams::detail::indirect_streambuf<T, Tr, Alloc, Mode>::open(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/stream_buffer.hpp:106:13:   required from ‘void boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::open_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/stream_buffer.hpp:94:5:   required from ‘boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::stream_buffer(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:257:60:   required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:216:1:   required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
/usr/local/include/boost/iostreams/chain.hpp:496:7:   required from ‘void boost::iostreams::detail::chain_client<Chain>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:484:1:   required from ‘void boost::iostreams::detail::chain_client<Chain>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
simple.cpp:6:47:   required from here
/usr/local/include/boost/iostreams/detail/adapter/concept_adapter.hpp:67:48: error: use of deleted function ‘boost::iostreams::basic_bzip2_compressor<>::basic_bzip2_compressor(const boost::iostreams::basic_bzip2_compressor<>&)’
In file included from /usr/local/include/boost/iostreams/detail/streambuf/direct_streambuf.hpp:26:0,
                 from /usr/local/include/boost/iostreams/stream_buffer.hpp:21,
                 from /usr/local/include/boost/iostreams/chain.hpp:35,
                 from /usr/local/include/boost/iostreams/filtering_streambuf.hpp:17,
                 from /usr/local/include/boost/iostreams/filtering_stream.hpp:22,
                 from simple.cpp:1:
/usr/local/include/boost/iostreams/detail/optional.hpp: In instantiation of ‘void boost::iostreams::detail::optional<T>::reset(const T&) [with T = boost::iostreams::detail::concept_adapter<boost::iostreams::basic_bzip2_compressor<> >]’:
/usr/local/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:187:5:   required from ‘void boost::iostreams::detail::indirect_streambuf<T, Tr, Alloc, Mode>::open(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/stream_buffer.hpp:106:13:   required from ‘void boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::open_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/stream_buffer.hpp:94:5:   required from ‘boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::stream_buffer(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:257:60:   required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:216:1:   required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
/usr/local/include/boost/iostreams/chain.hpp:496:7:   required from ‘void boost::iostreams::detail::chain_client<Chain>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:484:1:   required from ‘void boost::iostreams::detail::chain_client<Chain>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
simple.cpp:6:47:   required from here
/usr/local/include/boost/iostreams/detail/optional.hpp:100:9: error: use of deleted function ‘boost::iostreams::detail::concept_adapter<boost::iostreams::basic_bzip2_compressor<> >::concept_adapter(const boost::iostreams::detail::concept_adapter<boost::iostreams::basic_bzip2_compressor<> >&)’
In file included from /usr/local/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:23:0,
                 from /usr/local/include/boost/iostreams/stream_buffer.hpp:22,
                 from /usr/local/include/boost/iostreams/chain.hpp:35,
                 from /usr/local/include/boost/iostreams/filtering_streambuf.hpp:17,
                 from /usr/local/include/boost/iostreams/filtering_stream.hpp:22,
                 from simple.cpp:1:
/usr/local/include/boost/iostreams/detail/adapter/concept_adapter.hpp:38:7: note: ‘boost::iostreams::detail::concept_adapter<boost::iostreams::basic_bzip2_compressor<> >::concept_adapter(const boost::iostreams::detail::concept_adapter<boost::iostreams::basic_bzip2_compressor<> >&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/local/include/boost/iostreams/detail/adapter/concept_adapter.hpp:38:7: error: use of deleted function ‘boost::iostreams::basic_bzip2_compressor<>::basic_bzip2_compressor(const boost::iostreams::basic_bzip2_compressor<>&)’



In file included from /usr/local/include/boost/iostreams/traits.hpp:31:0,
                 from /usr/local/include/boost/iostreams/pipeline.hpp:18,
                 from /usr/local/include/boost/iostreams/detail/push.hpp:22,
                 from /usr/local/include/boost/iostreams/filtering_stream.hpp:19,
                 from simple.cpp:1:
/usr/local/include/boost/iostreams/detail/wrap_unwrap.hpp: In instantiation of ‘T boost::iostreams::detail::wrap(const T&, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’:
/usr/local/include/boost/iostreams/stream_buffer.hpp:94:5:   required from ‘boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::stream_buffer(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:257:60:   required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
4

1 回答 1

3

使用编译的-std=c++0x代码不会与没有编译的代码 ABI 兼容-std=c++0x。您需要在-std=c++0x启用的情况下自己构建 Boost;这可以通过将cxxflags参数传递给bjam/来完成b2

于 2012-07-06T19:48:26.557 回答