Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Examples

Example: std::swap. The basic swap template swaps two values a and b by creating a temp copy of a, assigning a = b, and assigning b = temp. How can you extend it for your own types? For example, let’s say you have your own type Widget in your own namespace N:

namespace N {
 class Widget { /* ... */ };
}


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint