VC. STL Newsgroup Good Questions (2)

Source: Internet
Author: User
VC. STL Newsgroup Good Questions (2)

When Templated Member Function is used, the C2664 compilation error occurs. Why?

Article last modified on 2002-5-29

----------------------------------------------------------------

The information in this article applies:

-Microsoft Visual C ++, 32-bit Editions, version 6.0, SP5

----------------------------------------------------------------

 

Question:

The following code reports C2664 errors during compilation:

Error C2664: '_ thiscall std: list >:: STD: List > (Unsigned int, const int &, const class std: allocator &) ': Cannot convert parameter 1 from 'class std: istream_iterator > (_ Cdecl *) (void) 'to 'unsigned int' This conversion requires a reinterpret_cast, a C-style cast or function-style cast

The Code is as follows:
Istream_iterator IntFileBegin ();

Istream_iterator IntFileEnd;

List IntList (intFileBegin, intFileEnd );

 

Answer:

When the vc6 library file is released, the compiler does not support the templated member function. In this way, the templated list constructor cannot obtain non-list iterators.

Although the compiler supports the templated member function, you still need a new standard library to compile the function. The previous code should be compiled in the following environment:

N vc 7

N vc6 with dinkumware library upgrade

N vc6 with stlport

 

If you do not have such a compiling environment, do not useTemplated member function. You can do this:


Istream_iterator Intfilebegin (CIN );

Istream_iterator Intfileend;

List IntList;

Copy (intfilebegin, intfileend, back_inserter (intlist ));

 

In this way, you can import the items in istream to the list.

 

(To be Continued)

 

Written by zhengyun@tomosoft.com

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? PostId = 12674

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.