会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
P.wang
博客园
首页
新随笔
联系
订阅
管理
1
2
3
4
5
下一页
2020年6月4日
A template Singleton class
摘要: 5年前在学校,写了一篇关于单例设计的Blog,最近需要写3个单例对象,如果每个对象都写一遍单例模式,显得很冗余。所以需要应用单例模板类。 基于之前的内容:https://www.cnblogs.com/wangpei0522/p/4460529.html 很容易扩展为使用模板继承的单例辅助类: 1
阅读全文
posted @ 2020-06-04 15:40 P.wang
阅读(187)
评论(0)
推荐(0)
2020年5月31日
std::shared_ptr alias constructor
摘要: struct X { int a; }; shared_ptr<X> px(new X); shared_ptr<int> pi(px, &px->a); shared_ptr<X> sp1(new X); shared_ptr<X> sp2(sp1, new X); // ERROR: delet
阅读全文
posted @ 2020-05-31 13:50 P.wang
阅读(175)
评论(0)
推荐(0)
2020年5月15日
Transform using the glm library
摘要: // Rotation /* Matrix to quaternion */ glm::quat q_from_matrix3x3{ glm::mat3{1} }; // cast operator will handle this glm::quat q_from_matrix4x4{ glm::
阅读全文
posted @ 2020-05-15 14:27 P.wang
阅读(420)
评论(0)
推荐(0)
2018年6月8日
C++11 Universal Reference
摘要: Q1. 什么是universal reference? If a variable or parameter is declared to have type T&& for some deduced type T, that variable or parameter is a universal
阅读全文
posted @ 2018-06-08 16:21 P.wang
阅读(334)
评论(0)
推荐(0)
2016年2月19日
intel xeon phi 常见错误记录
摘要: 本文记录我使用MIC过程中,常见的错误。 1. undefined symbol: _ZSt3maxIiERKT_S2_S2_" ... offload error: cannot load library to the device 0 (error code 20) 这个错误太难定位了,我最后使
阅读全文
posted @ 2016-02-19 15:28 P.wang
阅读(1006)
评论(2)
推荐(0)
2015年9月11日
__decspec(selectany)
摘要: 我们在使用宏定义一类的技术时,容易发生符号的重定义,特别在这个符号是全局变量时。可以使用__decspec(selectany)提示编译器,可以重定义此符号。1.cppint sym = 1;int main(){...}2.cppint sym = 1;void function(){...}//...
阅读全文
posted @ 2015-09-11 18:33 P.wang
阅读(369)
评论(0)
推荐(0)
2015年6月11日
温故知新——C++两个相互关联的类
摘要: 我们都必须意识到,写程序其实是一个心思要细腻的活~一开始,我的代码大概是这个样子的:class B;class A{public: A(){} A(int a) : id(a){} private: B b; };class B{ public: B(){} B(int b): ...
阅读全文
posted @ 2015-06-11 23:20 P.wang
阅读(627)
评论(0)
推荐(0)
2015年6月5日
Mitsuba中的智能指针ref<>和scheduler单例
摘要: Mitsuba中随处可见ref 和 scheduler先说说class ref, 它在include\mitsuba\core\ref.h中定义templateclass ref{public: /// Create a NULL reference ref() : m_ptr(NULL...
阅读全文
posted @ 2015-06-05 16:17 P.wang
阅读(510)
评论(0)
推荐(0)
2015年6月2日
do while(0)的作用
摘要: 阅读Mitsuba的代码的时候,发现了一个有意思的地方:#define Log(level, fmt, ...) do { \ mitsuba::Thread *thread = mitsuba::Thread::getThread(); \ if (EXPECT_NOT...
阅读全文
posted @ 2015-06-02 16:03 P.wang
阅读(6550)
评论(1)
推荐(0)
2015年5月31日
C++中限制对象的申请
摘要: 最近阅读Mitsuba的架构,有一个挺有意思的设计,开始没看明白。下面,我把限制对象的申请分两个方面讲述:1.限制对象在堆/栈上申请;2.限制对象申请的个数。//所有的资料,都可以在《more effective c++》上找到有一个基类Object,它的析构函数是protected访问权限的。并且...
阅读全文
posted @ 2015-05-31 16:47 P.wang
阅读(576)
评论(0)
推荐(0)
1
2
3
4
5
下一页
公告