⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 metafunctions.sgml

📁 boost库提供标准的C++ API 配合dev c++使用,功能更加强大
💻 SGML
字号:
<section id="metafunctions">
<title>Metafunctions</>

<para>
In &MPL;, the metaprogramming equivalent of a function is a <firstterm>class template</> containing a nested <literal>typedef</> member aptly named <quote>type</>:
</>

<programlisting>
<![CDATA[
// on the face of it, not very useful
template< typename T >
struct identity 
{
    typedef T type;
};

// perhaps more useful
template< typename T >
struct result_type 
{
    typedef typename T::result_type type;
};
]]>
</>

<para>
<quote>Invoking</> a metafunction is as simple as instantiating the class template with particular template parameters (metafunction <quote>arguments</>) and accessing the result through the nested <literal>type</> member:
</>

<programlisting>
<![CDATA[
typedef identity<int>::type t1; // t1 == int
typedef result_type< std::unary_function<int,bool> >::type t2; // t2 == bool
]]>
</>

</section>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -