• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 28, comments - 179, trackbacks - 0, articles - 1
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            什么是concept

            Posted on 2007-05-31 14:45 chemz 閱讀(2184) 評論(6)  編輯 收藏 引用 所屬分類: C++
                                              什么是concept
                在范型程序設計領域有一個必須要掌握的名詞“concept”,中文翻譯叫做“概念”,這個
            翻譯僅僅是一個concept英文的直譯,并沒有包含范型程序設計中concept的特定含義,要想
            真正的進入到范型程序設計領域,理解范型設計的思想,首先必須完全弄明白什么是concept?

                在《美國傳統詞典[雙解]》中,concept這一名詞被解釋為:
                1. A general idea derived or inferred from specific instances or occurrences.
                   概念:從特定情形或事件中得到或推斷出的一般性想法
                2. Something formed in the mind; a thought or notion.See Synonyms at idea.
                   想法:在腦海中形成的想法;思想或觀念參見 idea
                3. Usage Problem A scheme; a plan.
                   設想;計劃

                在范型程序設計的發源地SGI,在STL_DOC中有對什么是concept的專門的描述:
                “One very important question to ask about any template function, not just
                about STL algorithms, is what the set of types is that may correctly be
                substituted for the formal template parameters. Clearly, for example,
                int* or double* may be substituted for find's formal template parameter
                InputIterator. Equally clearly, int  or double may not: find uses the
                expression *first, and the dereference operator makes no sense for an
                object of type int  or of type double. The basic answer, then, is that
                find  implicitly defines a set of requirements on types, and that it may
                be instantiated with any type that satisfies those requirements. Whatever
                type is substituted for InputIterator must provide certain operations: it
                must be possible to compare two objects of that type for equality, it must
                be possible to increment an object of that type, it must be possible to
                dereference an object of that type to obtain the object that it points to,
                and so on.
                Find isn't the only STL algorithm that has such a set of requirements; the
                arguments to for_each and count, and other algorithms, must satisfy the same
                requirements. These requirements are sufficiently important that we give them
                a name: we call such a set of type requirements a concept, and we call this
                particular concept Input Iterator. We say that a type conforms to a concept,
                or that it is a model of a concept, if it satisfies all of those requirements.
                We say that int* is a model of Input Iterator because int* provides all of the
                operations that are specified by the Input Iterator requirements.
                Concepts are not a part of the C++ language; there is no way to declare a
                concept in a program, or to declare that a particular type is a model of a
                concept. Nevertheless, concepts are an extremely important part of the STL.
                Using concepts makes it possible to write programs that cleanly separate
                interface from implementation: the author of find only has to consider the
                interface specified by the concept Input Iterator, rather than the
                implementation of every possible type that conforms to that concept. Similarly,
                if you want to use find, you need only to ensure that the arguments you pass
                to it are models of Input Iterator. This is the reason why find and reverse
                can be used with lists, vectors, C arrays, and many other types: programming
                in terms of concepts, rather than in terms of specific types, makes it possible
                to reuse software components and to combine components together. ”
                
                侯捷在《Genericity/STL 大系》一文中將concept解釋為:(此處和SGI的說法吻合)
                “所謂 concept,描述某個抽象型別的條件(或說需求,requirements)。concept 并
                不是一個 class,也不是一個變數或是一個 template 叁數;C++ 語言之中沒有任何東
                西可以直接代表一個concept。然而,在每一個用到泛型程式設計方法的 C++ 程式中,
                concept 非常重要。由 concepts 所構成的階層體系,正是 STL 的主體結構。

                當某個型別滿足某個 concept 的所有條件,我們便說此型別是該 conecpt 的一個model。
                concept 可被視為一組型別條件。如果型別 T 是 concept C 的一個 model,那麼 T 就
                一定滿足 C 的所有條件。因此,concept 亦可被視為是一組型別。如果型別 T 是
                concept C 的一個 model,我們便可說 T 隸屬於「C 所表現的一組型別」”
               
                由上面的三種不同角度的解釋可以看出來,concept實際上應該是一個人在認識一種事物
            或現象的過程中總結或抽象出來的一種思想和設計,而由于人類在認知事物、現象和世界時
            均帶有自身的約束和局限,那么就決定了總結或抽象出來的思想和設計都具有一定的約束和
            局限,或者叫做具有一定的邊界(范圍)。那么在人們利用這些思想或設計重新審視一種
            事物或現象時,就會在這種思想和設計的邊界之內來進行判斷,在這個范圍內的我們稱之為
            符合這種概念,那么如何判斷一種事物或現象是否符合某個概念呢?一般情況下必須在這個
            concept下形成特殊的判斷條件,這些條件組合起來完成了一種concept和另外一種concept
            之間的區別,也就是條件的集合稱為了判斷一種事物或現象是否歸屬于某一個concept的依據。
            當然,不同的concept之間可能會有交集,但絕對不會完全重合。
                上面是一種一般性的極度抽象的解釋concept的方法,在將這種解釋應用到某一個實際的
            真實環境或領域時應該是如何的呢?我們需要給這個concept指定一個名稱,用于表示這個
            concept,同時我們還必須確定這個用于判斷一種事物或現象是否歸屬于這個concept的條件
            ,進而形成concept的判斷邊界(范圍,集合)。那么在范型程序設計中的concept就非常好
            理解了,比如:Iterator這樣的一種concept,同樣是在人們的程序設計過程中為了完成對
            容器對象中的元素進行訪問,而抽象和總結出來的處理類似問題域的一種思想或設計,那么
            經過更進一步的設計和構想,就會逐漸的將什么才能夠算得上是一個iterator的判斷依據
            確定下來,形成Iterator這一concept的邊界,也就是他形成了一些用于鑒別一個實例是否
            歸屬于一個concept范疇的條件集合(約束集),在軟件中這實際上就是一個實例必須具備
            concept所定義的接口形式和語義(包括編譯時和運行時),在Iterator概念中就必須明確
            的要求一個實例必須提供類似于++、--、*、==、!=等等這樣的接口形式和每一種接口所代
            表的語義,要注意形式和語義是缺一不可的,必須嚴格的符合,否則就不能夠算是符合某一
            個concept。
                其實concept就是這些東西,上面的解釋過于形式化,不太好理解。因為不是每一個都能
            很好的僅僅通過形式化的定義理解一個concept的形成條件、最初的問題域、和提出者的思想
            的(也就和一個代數公式一樣,必須要在他所形成和適用的環境中才能夠較容易的理解),這
            樣一來,人們會在concept形式化的描述中添加一些該concept最初的問題域的描述、形成時
            提出者的思想和初衷想法等,以幫助理解這個concept,所以就形成了STL_DOC和侯捷等其他人
            的有關concept就是一組需求的解釋,其實STL_DOC的解釋更為全面和準確。
                

            Feedback

            # re: 什么是concept  回復  更多評論   

            2007-05-31 14:52 by longshanks
            現在對concept有什么正式的譯法嗎?

            # re: 什么是concept[未登錄]  回復  更多評論   

            2007-05-31 16:14 by Joe
            那The Blocks Problem 是什么意思呢?

            # re: 什么是concept  回復  更多評論   

            2007-05-31 17:28 by vivilood
            Concept is what it looks like. Iterator is iterator since it looks like a iterator.

            # re: 什么是concept  回復  更多評論   

            2007-05-31 18:03 by danielwyo

            不知道你們在說什么, 裝得那么深奧.
            看看AOP的定義就知道了, 其實上就是一種AOP了.

            # re: 什么是concept  回復  更多評論   

            2007-06-04 14:14 by 看圖軟件
            概念讓我想起股市的題材,呵呵

            # re: 什么是concept  回復  更多評論   

            2009-05-16 00:26 by 卡門
            那么品牌稱呼是否可以說為“XXXX conception"??
            热99re久久国超精品首页| 久久免费视频1| 久久99久久成人免费播放| 欧美久久综合九色综合| 久久SE精品一区二区| 国产人久久人人人人爽 | 久久精品国产精品亜洲毛片| 久久这里有精品视频| 伊人久久大香线蕉av不卡| 国产一区二区三精品久久久无广告| 亚洲天堂久久久| 中文字幕亚洲综合久久| 久久精品国产色蜜蜜麻豆| 人人狠狠综合久久亚洲88| 久久久久国产精品人妻| 2020最新久久久视精品爱| 日韩av无码久久精品免费| 久久国产成人| 久久综合丝袜日本网| 国产精品女同久久久久电影院 | 97精品国产97久久久久久免费| 国内精品久久久久久久久电影网 | 思思久久99热免费精品6| 久久精品www| 91精品国产色综合久久| 亚洲精品无码久久久久| 久久综合亚洲色一区二区三区| 久久精品国产精品亚洲下载| 一本大道久久a久久精品综合| 色88久久久久高潮综合影院| 亚洲国产精品18久久久久久| 久久久久国色AV免费看图片| 99久久婷婷国产一区二区| 99久久er这里只有精品18| 久久午夜羞羞影院免费观看| 狠狠综合久久AV一区二区三区 | 99久久99这里只有免费费精品| 中文无码久久精品| 精品久久久久久久久午夜福利| 日日躁夜夜躁狠狠久久AV| 久久久久久久久无码精品亚洲日韩|