Consider the following code:
#include <vector>
#include
#include
struct IFooBar {
virtual void func() = 0;
};
typedef boost::any_range FooBarRange;
int main() {
std::vectorstd::unique_ptr<IFooBar> vec;
FooBarRange range = vec | boost::adaptors::indirected;
return 0;
}
Compilation fails with the following error ( looks like any_range value is
supposed to be copy-constructable? )
Is there any workaround?
boost_1_54_0, MSVC 2010
1>c:\users\voivoid\libs\boost_1_54_0\boost\range\detail\any_iterator_interface.hpp(90):
error C2259: 'IFooBar' : cannot instantiate abstract class
1> due to following members:
1> 'void IFooBar::func(void)' : is abstract
1> c:\users\voivoid\projects\cpptestapp\cpptestapp\main.cpp(9) :
see declaration of 'IFooBar::func'
1>
c:\users\voivoid\libs\boost_1_54_0\boost\range\detail\any_iterator_interface.hpp(93)
: see reference to class template instantiation
'boost::range_detail::any_single_pass_iterator_interface'
being compiled
1> with
1> [
1> Reference=IFooBar,
1> Buffer=boost::any_iterator_buffer<64>
1> ]
1>
c:\users\voivoid\libs\boost_1_54_0\boost\range\detail\any_iterator_interface.hpp(101)
: see reference to class template instantiation
'boost::range_detail::any_single_pass_iterator_interface'
being compiled
1> with
1> [
1> Reference=const IFooBar &,
1> Buffer=boost::any_iterator_buffer<64>
1> ]
1>
c:\users\voivoid\libs\boost_1_54_0\boost\range\detail\any_iterator_interface.hpp(123)
: see reference to class template instantiation
'boost::range_detail::any_forward_iterator_interface'
being compiled
1> with
1> [
1> Reference=const IFooBar &,
1> Buffer=boost::any_iterator_buffer<64>
1> ]
1>
c:\users\voivoid\libs\boost_1_54_0\boost\range\detail\any_iterator_interface.hpp(151)
: see reference to class template instantiation
'boost::range_detail::any_bidirectional_iterator_interface'
being compiled
1> with
1> [
1> Reference=const IFooBar &,
1> Buffer=boost::any_iterator_buffer<64>
1> ]
1>
c:\users\voivoid\libs\boost_1_54_0\boost\range\detail\any_iterator.hpp(452)
: see reference to class template instantiation
'boost::range_detail::any_random_access_iterator_interface'
being compiled
1> with
1> [
1> Reference=const IFooBar &,
1> Difference=ptrdiff_t,
1> Buffer=boost::any_iterator_buffer<64>
1> ]
1> c:\program files (x86)\microsoft visual studio
10.0\vc\include\xutility(385) : see reference to class template
instantiation
'boost::range_detail::any_iterator'
being compiled
1> with
1> [
1> Value=IFooBar,
1> Traversal=boost::random_access_traversal_tag,
1> Reference=const IFooBar &,
1> Difference=ptrdiff_t,
1> Buffer=boost::any_iterator_buffer<64>
1> ]
1> c:\users\voivoid\libs\boost_1_54_0\boost\detail\iterator.hpp(83)
: see reference to class template instantiation
'std::iterator_traits<_Iter>' being compiled
1> with
1> [
1>
_Iter=boost::range_detail::any_iterator>
1> ]
1>
c:\users\voivoid\libs\boost_1_54_0\boost\iterator\iterator_traits.hpp(30) :
see reference to class template instantiation
'boost::detail::iterator_traits<Iterator>' being compiled
1> with
1> [
1>
Iterator=boost::range_detail::any_iterator>
1> ]
1>
c:\users\voivoid\libs\boost_1_54_0\boost\range\iterator_range_core.hpp(141)
: see reference to class template instantiation
'boost::iterator_value<Iterator>' being compiled
1> with
1> [
1>
Iterator=boost::range_detail::any_iterator>
1> ]
1> c:\users\voivoid\libs\boost_1_54_0\boost\range\any_range.hpp(95)
: see reference to class template instantiation
'boost::iterator_range<IteratorT>' being compiled
1> with
1> [
1>
IteratorT=boost::range_detail::any_iterator>
1> ]
1> c:\users\voivoid\projects\cpptestapp\cpptestapp\main.cpp(19) :
see reference to class template instantiation
'boost::range_detail::any_range' being
compiled
1> with
1> [
1> Value=IFooBar,
1> Traversal=boost::random_access_traversal_tag,
1> Reference=const IFooBar &,
1> Difference=ptrdiff_t
1> ]
Thanks.
--
View this message in context: http://boost.2283326.n4.nabble.com/boost-any-range-with-an-abstract-class-re...
Sent from the Boost - Users mailing list archive at Nabble.com.