亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? introduction.sgml

?? boost庫提供標準的C++ API 配合dev c++使用,功能更加強大
?? SGML
?? 第 1 頁 / 共 2 頁
字號:
<section id="intro">
<title>Introduction</>

<para>
Metaprogramming is usually defined as the creation of programs which generate other programs. Parser generators such as YACC <citation><xref linkend="ref.Joh79"></> are examples of one kind of program-generating program. The input language to YACC is a context-free grammar in Extended Backus-Naur Form <citation><xref linkend="ref.EBNF"></>, and its output is a program which parses that grammar. Note that in this case the metaprogram (YACC) is written in a language (&C;) which does not directly support the description of generated programs. These specifications, which we'll call <emphasis>&mdat;</>, are not written in &C;, but in a <emphasis>meta-language</>. Because the the rest of the user's program typically requires a general-purpose programming system and must interact with the generated parser, the &mdat; is translated into &C;, which is then compiled and linked together with the rest of the system. The &mdat; thus undergoes two translation steps, and the user is always very conscious of the boundary between her &mdat; and the rest of her program.
</>

<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="intro.native">
<title>Native language metaprogramming</>

<para>
A more interesting form of &mping; is available in languages such as Scheme <citation><xref linkend="ref.SS75"></>, where the generated program specification is given in the same language as the metaprogram itself. The metaprogrammer defines her meta-language as a subset of the expressible forms of the underlying language, and program generation can take place in the same translation step used to process the rest of the user's program. This
allows users to switch transparently between ordinary programming, generated program specification, and &mping;, often without being aware of the transition.
</>
</section>

<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="intro.cxx">
<title>Metaprogramming in &Cxx;</>

<para>
In &Cxx;, it was discovered almost by accident <citation><xref linkend="ref.Unr"></>, <citation><xref linkend="ref.Vel95a"></> that the template mechanism provides a rich facility for computation at compile-time. In this section, we'll explore the basic mechanisms and some common idioms used for metaprogramming in &Cxx;.
</>

<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="intro.cxx.numeric">
<title>Numeric computations</>

<para>
The availability of <emphasis>non-type template parameters</> makes it possible to perform integer computations at compile-time. For example, the following template computes the factorial of its argument:
</>

<programlisting>
<![CDATA[
template< unsigned n >
struct factorial
{
    static const unsigned value = n * factorial<n-1>::value;
};

template<>
struct factorial<0>
{
    static const unsigned value = 1;
};
]]>
</>

<para>
The program fragment above is called a <emphasis>&mfn;</>, and it is easy to see its relationship to a function designed to be evaluated at runtime: the <quote>&mfn; argument</> is passed as a template parameter, and its <quote>return value</> is defined as a nested static constant. Because of the hard line between the expression of compile-time and runtime computation in &Cxx;, metaprograms look different from their runtime counterparts. Thus, although as in Scheme the &Cxx; metaprogrammer writes her code in the same language as the ordinary program, only a subset
of the full &Cxx; language is available to her: those expressions which can be evaluated at compile-time. Compare the above with a straightforward runtime definition of the factorial function:
</>

<programlisting>
unsigned factorial(unsigned N)
{
    return N == 0 ? 1 : N * factorial(N - 1);
}
</>

<para>
While it is easy to see the analogy between the two recursive definitions, recursion is in general more important to &Cxx; metaprograms than it is to runtime &Cxx;. In contrast to languages such as Lisp where recursion is idiomatic, &Cxx; programmers will typically avoid recursion when possible. This is done not only for efficiency reasons, but also because of <quote>cultural momentum</>: recursive programs are simply harder (for &Cxx; programmers) to think about. Like pure Lisp, though, the &Cxx; template mechanism is a <emphasis>functional</> programming language: as such it rules out the use of data mutation required to maintain loop variables.
</>

<para>
A key difference between the runtime and compile-time factorial functions is the expression of the termination condition: our meta-factorial uses template specialization as a kind of <emphasis>pattern-matching</> mechanism to describe the behavior when <literal>N</> is zero. The syntactic analogue in the runtime world would require two separate definitions of the same function. In this case the impact of the second definition is minimal, but in large
metaprograms the cost of maintaining and understanding the terminating definitions can become significant.
</>

<para>
Note also that a &Cxx; &mfn;'s return value must be <emphasis>named</>. The name chosen here, <literal>value</>, is the same one used for all numeric returns in the &MPL;. As we'll see, establishing a consistent naming
convention for &mfn; returns is crucial to the power of the library.
</>
</section>

<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="intro.cxx.type">
<title>Type computations</>

<para>
How could we apply our <literal>factorial</> &mfn;? We might, for example, produce an array type of an appropriate size to hold all permutations of instances of another type:
</>

<programlisting>
<![CDATA[
// permutation_holder<T>::type is an array type which can contain 
// all permutations of a given T.

// unspecialized template for scalars
template< typename T >
struct permutation_holder
{
    typedef T type[1][1];
};

// specialization for array types
template< typename T, unsigned N >
struct permutation_holder<T[N]>
{
    typedef T type[factorial<N>::value][N];
};
]]>
</>

<para>
Here we have introduced the notion of a <emphasis>type computation</>.  Like <literal>factorial</> above, <literal>permutation_holder</> template is a &mfn;. However, where <literal>factorial</> manipulates unsigned integer values, <literal>permutation_holder</> accepts and <quote>returns</> a type (as the nested typedef <literal>type</>). Because the &Cxx; type system provides a much richer set of expressions than anything we can use as a nontype template argument (e.g. the integers), &Cxx; metaprograms tend to be composed mostly of type computations.
</>
</section>

<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="intro.cxx.seq">
<title>Type sequences</>

<para>
The ability to programmatically manipulate collections of types is a central tool of most interesting &Cxx; metaprograms. Because this capability is so well-supported by the &MPL;, we'll provide just a brief
introduction to the basics here. Later on, we'll revisit the example below to show how it can be implemented using &MPL;.
</>

<para>
First, we'd need a way to represent the collection. One idea might be to store the types in a structure:
</>

<programlisting>
<![CDATA[
struct types
{
    int t1;
    long t2;
    std::vector<double> t3;
};
]]>
</>

<para>
Unfortunately, this arrangement is not susceptible to the compile-time type introspection power that &Cxx; gives us: there's no way to find out what the names of the members are, and even if we assume that they're named according to some convention as above, there's no way to know how many members there are. The key to solving this problem is to
increase the uniformity of the representation. If we have a consistent way to get the first type of any sequence and the rest of the sequence, we can easily access all members:
</>

<programlisting>
<![CDATA[
template< typename First, typename Rest >
struct cons
{
    typedef First first;
    typedef Rest rest;
};

struct nil {};

typedef
      cons<int
    , cons<long
    , cons<std::vector<double>
    , nil
    > > > my_types;
]]>
</>

<para>
The structure described by <literal>types</> above is the compile-time analogue of a singly-linked list; it has been first introduced by Czarnecki and Eisenecker in <citation><xref linkend="ref.ce98"></>. Now that we've adjusted the structure so that the &Cxx; template machinery can <quote>peel it apart</>, let's examine a simple metafunction which does so. Suppose a user wished to find the largest of an arbitrary collection of types. We can apply the recursive &mfn; formula which should by now be familiar:
</>

<example id="example.largest">
<title>'largest' metafunction</>
<programlisting>
<![CDATA[
// choose the larger of two types
template<
      typename T1
    , typename T2
    , bool choose1 = (sizeof(T1) > sizeof(T2)) // hands off!
    >
struct choose_larger
{
    typedef T1 type;
};

// specialization for the case where sizeof(T2) >= sizeof(T1)
template< typename T1, typename T2 >
struct choose_larger< T1,T2,false >
{
    typedef T2 type;
};

// get the largest of a cons-list
template< typename T > struct largest;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久不见久久见免费视频1| 日韩久久精品一区| 极品少妇一区二区| 91精品国产欧美一区二区成人| 香蕉成人啪国产精品视频综合网| 在线观看视频一区二区| 亚洲综合色在线| 欧美三区在线观看| 日本在线观看不卡视频| 精品少妇一区二区三区免费观看 | 26uuu另类欧美亚洲曰本| 美女脱光内衣内裤视频久久影院| 欧美一区二区三区四区高清| 蜜桃免费网站一区二区三区| 久久一留热品黄| 97久久超碰国产精品| 亚洲3atv精品一区二区三区| 日韩免费高清av| 成+人+亚洲+综合天堂| 亚洲激情在线激情| 精品国产乱码久久久久久影片| 成人自拍视频在线观看| 亚洲在线免费播放| 日韩视频免费观看高清完整版 | 精品久久久久99| 成人综合婷婷国产精品久久蜜臀| 亚洲激情av在线| 日韩女优制服丝袜电影| 成人毛片老司机大片| 午夜亚洲国产au精品一区二区| 欧美变态tickling挠脚心| 成人sese在线| 麻豆一区二区三| 亚洲欧美日韩在线不卡| 欧美va亚洲va香蕉在线 | 欧美午夜精品一区| 国产一区二区h| 亚洲一区二区三区四区五区中文| 精品久久久久久亚洲综合网| 一本大道av伊人久久综合| 久久成人羞羞网站| 亚洲乱码国产乱码精品精的特点| 精品国产免费一区二区三区四区 | 国产视频一区不卡| 欧美区视频在线观看| 成人国产精品免费观看动漫| 麻豆91精品91久久久的内涵| 亚洲精品自拍动漫在线| 久久噜噜亚洲综合| 欧美高清性hdvideosex| 91在线精品一区二区| 激情文学综合网| 日韩经典一区二区| 亚洲欧美日韩中文播放| 国产视频一区在线观看 | 日韩一区二区在线观看视频| 色综合久久中文字幕综合网| 国产999精品久久| 久久黄色级2电影| 香蕉加勒比综合久久| 亚洲欧美在线视频| 国产欧美一区二区精品仙草咪| 欧美一区二区成人| 欧美日韩第一区日日骚| 色狠狠一区二区| 9i看片成人免费高清| 粉嫩av一区二区三区| 国产美女在线精品| 国产裸体歌舞团一区二区| 老司机一区二区| 日韩高清电影一区| 视频一区在线播放| 成人动漫av在线| 国产不卡在线播放| 国产成人精品一区二区三区网站观看| 九九国产精品视频| 九九久久精品视频| 国产裸体歌舞团一区二区| 国产精品一区二区三区网站| 国产在线精品免费av| 久久精品免费看| 精品一区二区av| 精品一二线国产| 国产精品一区三区| 成人性生交大片免费看在线播放| 国产不卡在线一区| av在线一区二区三区| 波多野结衣的一区二区三区| 99久久免费精品| 色偷偷久久一区二区三区| 日本福利一区二区| 欧美性大战xxxxx久久久| 欧美日韩电影在线| 国产精品系列在线播放| 91视视频在线观看入口直接观看www | 亚洲情趣在线观看| 亚洲蜜桃精久久久久久久| 一区二区三区欧美激情| 亚洲一区免费视频| 视频一区二区中文字幕| 天堂午夜影视日韩欧美一区二区| 日本成人在线一区| 国产一区二区日韩精品| 成人黄色免费短视频| 99久久精品国产网站| 国产精品影视天天线| 国产一区二三区好的| 国产乱对白刺激视频不卡| 成人高清免费在线播放| 日本不卡一区二区三区高清视频| 午夜精品爽啪视频| 视频精品一区二区| 欧美体内she精高潮| 在线国产电影不卡| 欧美在线看片a免费观看| 欧美性淫爽ww久久久久无| 在线观看亚洲精品视频| 99国内精品久久| 欧美福利电影网| 久久一夜天堂av一区二区三区| 久久精品亚洲乱码伦伦中文| 国产精品成人一区二区艾草 | 欧美性猛交xxxx乱大交退制版| 色婷婷久久久久swag精品 | 精品久久久久久久久久久久包黑料| 久久综合久久综合久久综合| 国产女人aaa级久久久级| 综合色中文字幕| 久久aⅴ国产欧美74aaa| 国产成人av网站| 在线免费不卡电影| 欧美大片顶级少妇| 国产精品三级视频| 亚洲激情欧美激情| 精品伊人久久久久7777人| caoporn国产精品| 欧美在线高清视频| 国产精品久久久久久久午夜片 | 一区二区三区中文字幕精品精品 | 亚洲一区成人在线| 国产一区日韩二区欧美三区| 欧美日韩黄色影视| 国产日韩欧美激情| 亚洲国产中文字幕在线视频综合| 大胆欧美人体老妇| 日韩一区二区三区电影在线观看| 久久综合久久99| 亚洲精品成人悠悠色影视| 亚洲色图欧洲色图| 黄色小说综合网站| 欧美亚洲动漫另类| 国产校园另类小说区| 亚洲欧美自拍偷拍色图| 成人综合婷婷国产精品久久| 欧美一卡在线观看| 一区二区三区自拍| 粗大黑人巨茎大战欧美成人| 欧美综合一区二区| 亚洲乱码国产乱码精品精小说| 国产一区二区三区在线观看免费| 色婷婷久久99综合精品jk白丝| 26uuu久久天堂性欧美| 亚洲第一搞黄网站| 91在线观看高清| 日本一区二区三区在线不卡| 理论电影国产精品| 欧美久久一区二区| 亚洲影视资源网| gogogo免费视频观看亚洲一| 2欧美一区二区三区在线观看视频| 午夜久久久久久久久| 色综合久久久久综合体| 久久久99免费| 麻豆国产一区二区| 精品国产3级a| 狠狠久久亚洲欧美| 日韩亚洲欧美高清| 爽好多水快深点欧美视频| 91麻豆精品国产自产在线 | 夜夜夜精品看看| 97aⅴ精品视频一二三区| 国产女主播视频一区二区| 国产精品99久久久| 欧美群妇大交群中文字幕| 日产欧产美韩系列久久99| 欧美三区在线观看| 亚洲123区在线观看| 欧美日韩国产免费一区二区| 琪琪久久久久日韩精品| 91精品午夜视频| 日本美女一区二区| 欧美人妇做爰xxxⅹ性高电影| 椎名由奈av一区二区三区| 欧美性感一区二区三区| 亚洲午夜在线电影| 欧美日韩色综合| 日韩黄色免费电影| 久久久噜噜噜久久中文字幕色伊伊| 久久精品国产99国产精品| 久久精品亚洲一区二区三区浴池|