本文介紹了如何定義遞歸概念?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
cppreference.com 指出:
概念不能遞歸地引用自己
Concepts cannot recursively refer to themselves
但是我們?nèi)绾味x一個(gè)概念來表示整數(shù)或整數(shù)向量,或整數(shù)向量的向量等.
But how can we define a concept that will represent an integer or a vector of integers, or a vector of vector of integers, etc.
我可以擁有這樣的東西:
I can have something this:
但我想要像 IIntX
這樣的東西,這意味著任何 N 的 IIntN.
But I want to have something like IIntX
that will mean IIntN for any N.
有可能嗎?
推薦答案
概念總是可以遵從類型特征:
Concepts can always defer to a type trait:
而且這個(gè)特征可以遞歸:
And that trait can be recursive:
如果你的意思不只是vector
,那么最后的部分特化可以推廣為:
If you don't mean just vector
, then the last partial specialization can be generalized to:
這篇關(guān)于如何定義遞歸概念?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!