摘要: 5年前在学校,写了一篇关于单例设计的Blog,最近需要写3个单例对象,如果每个对象都写一遍单例模式,显得很冗余。所以需要应用单例模板类。 基于之前的内容:https://www.cnblogs.com/wangpei0522/p/4460529.html 很容易扩展为使用模板继承的单例辅助类: 1 阅读全文
posted @ 2020-06-04 15:40 P.wang 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(168) 评论(0) 推荐(0) 编辑
摘要: // 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 阅读(354) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 本文记录我使用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 阅读(927) 评论(2) 推荐(0) 编辑
摘要: 我们在使用宏定义一类的技术时,容易发生符号的重定义,特别在这个符号是全局变量时。可以使用__decspec(selectany)提示编译器,可以重定义此符号。1.cppint sym = 1;int main(){...}2.cppint sym = 1;void function(){...}//... 阅读全文
posted @ 2015-09-11 18:33 P.wang 阅读(352) 评论(0) 推荐(0) 编辑
摘要: 我们都必须意识到,写程序其实是一个心思要细腻的活~一开始,我的代码大概是这个样子的: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 阅读(602) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(500) 评论(0) 推荐(0) 编辑
摘要: 阅读Mitsuba的代码的时候,发现了一个有意思的地方:#define Log(level, fmt, ...) do { \ mitsuba::Thread *thread = mitsuba::Thread::getThread(); \ if (EXPECT_NOT... 阅读全文
posted @ 2015-06-02 16:03 P.wang 阅读(6479) 评论(1) 推荐(0) 编辑
摘要: 最近阅读Mitsuba的架构,有一个挺有意思的设计,开始没看明白。下面,我把限制对象的申请分两个方面讲述:1.限制对象在堆/栈上申请;2.限制对象申请的个数。//所有的资料,都可以在《more effective c++》上找到有一个基类Object,它的析构函数是protected访问权限的。并且... 阅读全文
posted @ 2015-05-31 16:47 P.wang 阅读(558) 评论(0) 推荐(0) 编辑