
On 6/11/2010 3:38 PM, Neal Becker wrote:
It seems an iterator requires a default constructor in order to be adapted by iterator adaptor.
This is due to (iterator_adaptor.hpp):279
iterator_adaptor() {}
Is this really necessary?
I believe if it never gets (explicitly or implicitly) instantiated, you're okay. E.g., on MSVC9, the following compiles, even though X< int& > isn't default constructible. #include <boost/call_traits.hpp> template< class T > struct X { X() { } X(typename boost::call_traits<T>::param_type x) : m_x(x) { } T m_x; }; int main(int argc, char* argv[]) { X<int> x; X< int& > y(x.m_x); return 0; } However, an explicit instantiation of X< int& > *will* generate a compiler error, but I imagine explicit instantiations of iterators are infrequent at best. All of the STL containers (AFAIK) declare a default constructor as iterator_adaptor does, regardless of their Allocator template parameter, even if the underlying allocator isn't default constructible, so it seems to be a rather pervasive situation. - Jeff