October 12, 2005

Manage Your STL Container’s Storage with Self-swapping Idioms

enerally, STL containers handle their storage automatically and efficiently. Yet, there are cases when you need to regulate a container’s storage manually?for example when you want to trim or empty it. This article shares two simple and effective techniques to accomplish these tasks. How do you trim a container whose

Protect Smart Pointers by Providing Multiple Interfaces

In general, when a smart pointer is designed, the usual methods proivided are: T* operator->() const and T operator*() const. So, in functions such as foo(const SmartPointer& ptr) { }, what is meant by “const“? You can’t reassign ptr, of course?and further, you can only call const methods on the

Locate All Stored Procedures and Their Objects/SQL Tables

Sometimes, for documentation purposes, you need to locate all the stored procedures and objects/SQL tables upon which they depend. The following code shows you how: select distinct A.name as sproc_name, C.name as dep_obj_name, C.xtype as dep_xtypefrom sysobjects Ainner join sysdepends SD on A.id=SD.idinner join sysobjects C on SD.depid=C.id and C.xtype

Use the “as” Operator for Reference Type Casting

Normally, people do casting in the code like this: Button btnSave = (Button) sender ;where sender is of Object Type. This same casting can be done using the as operator: Button btnSave = sender as Button; There are two advantages to using the as operator: It makes your code more

Tackle Device Fragmentation with NetBeans and the NetBeans Mobility Pack

ince its inception, “write once, run anywhere!” has been the mantra and rallying cry for many architects and software engineers trying to convince their enterprises to move to or stay with Java. The phrase was particularly useful when talking about building software applications for mobile and wireless devices. If you