Effective C + + notes

Source: Internet
Author: User
Chapter 7 templates and generic programming Item 41

For template parameters, the interface is implicit and only when instantiated, does it check that the actual template type supports the interface in the template

Item 42
template <typename C>void print2nd(const C& container) {    C::const_iterator* x;}

As in the code, if you do not prefix const::iterator with TypeName, the compiler will not assume that it is a type, which will create ambiguity. Perhaps const_iterator is a static variable of a class, resulting in an explanation of multiplying by X.

However, TypeName can only be used with nested dependent type, such as

template <typename C>void f(const C& container, typename C::iterator iter);

C is automatically deduced, and only ITER needs to mark it as type.

Effective C + + notes

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.