Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2001-10-11 08:33:30


On Thursday, October 11, 2001, at 07:13 AM, Peter Dimov wrote:

> Let's go back to the original question: is std::ostringstream a complete
> type after <sstream> has been included?

I'm not sure (and I would like to be).

I've read 27.7 and the only thing I can say for sure is that after
including <sstream> std::ostringstream is a typedef for
std::basic_ostringstream<char>. And std::basic_ostringstream<charT +
defaults> is a class _template_.

So perhaps the question can be reworded: Is a class template a complete
type?

template <class T> struct A;

template <class T>
struct B
        : A<T>
{
};

B<T> is a class template now. Is it a complete type? Or is it just a
template for a type?

template <class T>
struct C
        : T
{
};

Is C<T> a complete type now? I'm not positive that a class template can
constitute a complete type. However I think we both agree that a class
instantiated from a class template *is* a complete type.

I think the real question is: Can std::ostringstream be instantiated
after including <sstream>? I hope the answer is yes.

Before we get too far down the inheritance argument, there are other
examples which don't include inheritance. Is this portable code?

#include <string>

int
main()
{
        std::string s;
}

I hope yes. But we've just instantiated and constructed a
std::allocator<char> (at least conceptually) which is defined over in
<memory>.

template<class charT, class traits = char_traits<charT>,
          class Allocator = allocator<charT> >
class basic_string
{
        ...
        explicit basic_string(const Allocator& a = Allocator());
        ...
};

Do we need to include <memory>? I hope not. But how do we know that we
don't need to include <memory>? Once we've decided that we don't need
to include <memory> in the above example, is this code legal:

#include <string>

int
main()
{
        std::allocator<char> a;
}

I hope not. Though I'm guessing it would work on most of today's
platforms anyway.

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk