~ubuntu-branches/ubuntu/trusty/c++-annotations/trusty

« back to all changes in this revision

Viewing changes to yo/advancedtemplates/overloaded.yo

  • Committer: Package Import Robot
  • Author(s): Frank B. Brokken
  • Date: 2011-09-12 16:08:05 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: package-import@ubuntu.com-20110912160805-r9dq68beojgzuien
Tags: 9.0.2-1
New upstream release (editorial changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
    Template meta programming comes to the rescue. Knowing that class template
2
2
member functions are only instantiated when used, our plan is to design
3
 
overloaded tt(add) member functions of which only one will be called (and thus
4
 
instantiated). Our selection will be based on an additional (in addition to
5
 
tt(Type) itself) template non-type parameter that indicates whether we'll use
6
 
tt(Storage) for polymorphic or non-polymorphic classes. Our class tt(Storage)
7
 
starts like this:
 
3
overloaded tt(add) member functions of which only one is going to be called
 
4
(and thus instantiated). Our selection will be based on an additional (in
 
5
addition to tt(Type) itself) template non-type parameter that indicates
 
6
whether we'll use tt(Storage) for polymorphic or non-polymorphic classes. Our
 
7
class tt(Storage) starts like this:
8
8
        verb(
9
9
    template <typename Type, bool isPolymorphic>
10
10
    class Storage