
模板元编程
文章平均质量分 55
yeqm_
作为解题记录
展开
-
模板元编程 第二章练习(非答案)
2-0.编写一个一元元函数 add_const_ref,如果T是一个引用类型,就返回T,否则返回T const&。编写一个程序来测试你的元函数。提示:可以使用boost::is_same来测试结果。boost::add_const 对引用没有效果。。#ifndef ITER_SWAP_H#define ITER_SWAP_H#include#include#include#in原创 2015-11-19 20:12:24 · 478 阅读 · 0 评论 -
模板元编程 第三章课后练习(非答案)
3-0templatestruct cal{ BOOST_STATIC_ASSERT((N%10>=0)); BOOST_STATIC_ASSERT((N%10<2)); static const int val = 2*cal::val+N%10;};template<>struct cal{ static const int val = 0;};3-1,3-2原创 2015-11-26 12:45:25 · 474 阅读 · 0 评论 -
模板元编程第四章练习(非答案)
4-0using namespace std;using namespace boost;using namespace mpl::placeholders;templatestruct is_a{ static const bool value = 0;};templatestruct is_b{ static const bool value = boost::i原创 2015-11-30 12:42:30 · 373 阅读 · 0 评论 -
模板元编程第六章课后习题(非答案)20151206
//6-0template<bool,class T1,class T2>struct T1smallest{ typedef T1 type;};template<class T1,class T2>struct T1smallest<false,T1,T2>{ typedef T2 type;};template<class T1,class T2>struct T原创 2015-12-05 16:25:14 · 745 阅读 · 0 评论 -
模板元编程第五章练习(非答案)
“` 5-1 //5-1 template原创 2015-12-03 13:13:58 · 313 阅读 · 0 评论 -
模板元编程第九章练习(非答案)
9-0#ifdef NO_MI_EBOtemplateclass storage;templateclass storage_imp:private T{protected:public: storage_imp(T const& t):T(t){} T const& get_t(){return *this;}};templateclass storage:public原创 2015-12-13 13:51:03 · 375 阅读 · 0 评论