久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

將導出關鍵字與模板一起使用

Using export keyword with templates(將導出關鍵字與模板一起使用)
本文介紹了將導出關鍵字與模板一起使用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

據我所知,可以使用export"關鍵字,以便可以通過頭文件公開模板類或函數簽名,并在庫文件中抽象實際實現.
誰能提供一個實用的示例程序來展示如何做到這一點?
使用時有什么缺點或要注意的要點嗎?

As i Understand "export" keyword can be used so that one can expose template classes or function signatures through an header file and abstract the actual implementation in a library file.
Can anyone please provide a practical sample program which shows how to do this?
Are there any disadvantages or important points to note while using this?

基于答案的后續問題.正如答案中提到的那樣,導出"在 C++0x 中已被棄用,即使對于 C++03x,編譯器也很少支持.在這種情況下,我們可以通過什么方式隱藏 lib 文件中的實際實現并僅通過頭文件公開聲明,以便最終用戶可以知道公開 API 的簽名是什么,但無法訪問實現相同的源代碼?

A follow up question based on the answers. As mentioned in the answers 'export' is deprecated in C++0x and rarely supported by compilers even for C++03x. Given this situation, in what way can one hide actual implementations in lib files and just expose declarations through header files, So that end user can know what are the signatures of the exposed API but not have access to the source code implementing the same?

推薦答案

首先:大多數編譯器(包括 gcc、Clang 和 Visual Studio)不支持 export 關鍵字.

First of all: most compilers (including gcc, Clang and Visual Studio) do not support the export keyword.

它已在單個前端實現:EDG 前端,因此只有使用它的編譯器(Comeau 和 icc)支持此功能.EDG 實現者的反饋非常簡單:花費了我們時間,非常復雜,我們建議不要實現它 (1),因此它已在 C++0x 中刪除.

It has been implemented in a single front-end: the EDG front-end, and thus only the compilers that use it (Comeau and icc) support this feature. The feedback from the implementers at EDG was extremely simple: it took us time, was extremely complicated, we recommend not to implement it (1), as a consequence it has been dropped in C++0x.

現在,標準允許(至少由 gcc 實現):

Now, the standard allows (and this is implemented by at least gcc):

  • 在標頭中聲明模板函數的專用版本
  • 在單個源文件中定義此專業化

并讓它像您對常規函數所期望的那樣運行.

and to have it behave as you'd expect from a regular function.

注意:正如 Johannes 在評論中指出的那樣,如果在標頭中定義了函數的完整特化,則必須將其標記為內聯,否則鏈接器會報錯.

(1) 終于找到我的參考為什么我們不能負擔得起出口 (PDF) 作者:Tom Plum,由 Edison Design Group 的 Steve Adamczyk、John Spicer 和 Daveed Vandevoorde 審閱,他們最初在 EDG 前端實施.

(1) Finally found my reference Why can't we afford export (PDF) by Tom Plum, reviewed by Steve Adamczyk, John Spicer, and Daveed Vandevoorde of Edison Design Group who originally implemented it in the EDG front end.

這篇關于將導出關鍵字與模板一起使用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區別?)
Difference between const. pointer and reference?(常量之間的區別.指針和引用?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內容?)
Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進行多態?)
Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會導致訪問沖突?)
主站蜘蛛池模板: 欧美激情精品久久久久久免费 | 激情一区二区三区 | 91在线成人 | 91天堂 | 日韩精品一区二区三区中文在线 | 亚洲国产视频一区二区 | 中文字幕免费在线 | 久久精品亚洲精品国产欧美 | 亚洲精品乱码久久久久久按摩 | 精品不卡| 久久久久久久久99 | 一级毛片视频 | 久久一区视频 | 久久爱一区 | 国产精品欧美一区二区三区不卡 | www.国产精品 | 99pao成人国产永久免费视频 | 水蜜桃久久夜色精品一区 | 日本涩涩视频 | 亚洲午夜精品一区二区三区 | 最新国产在线 | 精品国产一区二区三区在线观看 | 一区二区三区亚洲 | 欧美精品一区三区 | 在线视频中文字幕 | 国产亚洲精品精品国产亚洲综合 | 精品中文在线 | 日韩和的一区二区 | 久久久精品一区 | 亚洲二区在线 | 五月天婷婷激情 | 黄色毛片在线观看 | 精品成人69xx.xyz| 亚洲欧美日韩国产综合 | 国产午夜精品一区二区三区四区 | 国产日韩欧美中文字幕 | 久久精品国产一区二区电影 | 欧美激情精品久久久久久 | 国产清纯白嫩初高生视频在线观看 | 中文字幕高清在线 | 伊人狠狠干 |