How can a normal compilation be achieved after the template class declaration header file and the implementation file are detached in C + +?

Source: Internet
Author: User
The sixth chapter of C + + Template says this question
There are three ways to organize your template code
1. Include the model (general notation writes the implementation in the header file)
2. Explicit instantiation (Implementation written in CPP file, explicitly instantiated using template class syntax)
3. Detach the model (export using the C + + export keyword Declaration)

The third approach is theoretically optimal, but the main compiler has not supported it since the C + + standard, and has abolished this feature in the latest C++11 standard, and the Export keyword remains pending.
Then there is only an explicit instantiation of the implementation separation that can actually be used

Interestingly, the author of the C + + Template suggested that the code be prepared for the separation model, waiting for the compiler to replace it, and unexpectedly this feature was discarded by the C + + standard.

Tang Yu
Links: http://www.zhihu.com/question/20630104/answer/80220897
Source: Know
Copyright belongs to the author, please contact the author for authorization.

How can a normal compilation be achieved after the template class declaration header file and the implementation file are detached in C + +?

Related Article

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.