Ray's playground

 
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 56 下一页

2011年4月9日

Item 48: Be aware of template metaprogramming(Effective C++)

摘要: Template metaprogramming can shift work from runtime to compile-time, thus enabling earlier error detection and higher runtime performance. TMP can be used to generate custom code based on combinations of policy choices, and it can also be used to avoid generating code inappropriate for particular . 阅读全文

posted @ 2011-04-09 10:39 Ray Z 阅读(158) 评论(0) 推荐(0) 编辑

2011年4月8日

Item 47: Use traits classes for information about types(Effective C++)

摘要: Traits classes make information about types available during compilation. They're implemented using templates and template specializations. In conjunction with overloading, traits classes make it possible to perform compile-time if...else tests on types. 阅读全文

posted @ 2011-04-08 22:03 Ray Z 阅读(129) 评论(0) 推荐(0) 编辑

Item 46: Define non-member functions inside templates when type conversions are desired(Effective C++)

摘要: When writing a class template that offers functions related to the template that support implicit type conversions on all parameters, define those functions as friends inside the class template. 阅读全文

posted @ 2011-04-08 11:56 Ray Z 阅读(195) 评论(0) 推荐(0) 编辑

2011年4月7日

Item 45: Use member function templates to accept "all compatible types."(Effective C++)

摘要: Use member function templates to generate functions that accept all compatible types. If you declare member templates for generalized copy construction or generalized assignment, you'll still need to declare the normal copy constructor and copy assignment operator, too. 阅读全文

posted @ 2011-04-07 18:27 Ray Z 阅读(164) 评论(0) 推荐(0) 编辑

2011年4月6日

Item 44: Factor parameter-independent code out of templates(Effective C++)

摘要: Templates generate multiple classes and multiple functions, so any template code not dependent on a template parameter causes bloat. Bloat due to non-type template parameters can often be eliminated by replacing template parameters with function parameters or class data members. Bloat due to type p. 阅读全文

posted @ 2011-04-06 20:27 Ray Z 阅读(204) 评论(0) 推荐(0) 编辑

Core Data Relationships(Chapter 30 of Cocoa Programming for Mac OS X)

摘要: 1#import"Department.h"2#import"Employee.h"34@implementationDepartment5@dynamicdeptName;6@dynamicemployees;7@dynamicmanager;89/*10-(void)addEmployeesObject:(NSManagedObject*)value{11NSSet*changedObjects=[[NSSetalloc]initWithObjects:&valuecount:1];12[selfwillChangeValueForKey:@ 阅读全文

posted @ 2011-04-06 19:59 Ray Z 阅读(230) 评论(0) 推荐(0) 编辑

Item 43: Know how to access names in templatized base classes(Effective C++)

摘要: In derived class templates, refer to names in base class templates via a "this->" prefix, via using declarations, or via an explicit base class qualification. 阅读全文

posted @ 2011-04-06 10:02 Ray Z 阅读(177) 评论(0) 推荐(0) 编辑

2011年4月5日

Item 41: Understand implicit interfaces and compile-time polymorphism(Effective C++)

摘要: Both classes and templates support interfaces and polymorphism. For classes, interfaces are explicit and centered on function signatures. Polymorphism occurs at runtime through virtual functions. For template parameters, interfaces are implicit and based on valid expressions. Polymorphism occurs du. 阅读全文

posted @ 2011-04-05 21:41 Ray Z 阅读(228) 评论(0) 推荐(0) 编辑

Item 40: Use multiple inheritance judiciously(Effective C++)

摘要: Multiple inheritance is more complex than single inheritance. It can lead to new ambiguity issues and to the need for virtual inheritance. Virtual inheritance imposes costs in size, speed, and complexity of initialization and assignment. It's most practical when virtual base classes have no data 阅读全文

posted @ 2011-04-05 10:36 Ray Z 阅读(167) 评论(0) 推荐(0) 编辑

Script Execution Context(Chapter 3 of Programming Python)

摘要: 1importsys23classOutput:4def__init__(self):5self.text=''6defwrite(self,string):7self.text+=string8defwritelines(self,lines):9forlineinlines:10self.write(line)1112classInput:13def__init__(self,input=''):14self.text=input15defread(self,size=None):16ifsize==None:17res,self.text=self.tex 阅读全文

posted @ 2011-04-05 09:56 Ray Z 阅读(275) 评论(0) 推荐(0) 编辑

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 56 下一页

导航