diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-25 13:42:07 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-25 13:42:07 +0000 |
commit | 302bdc13a9baebb21894673e7674f4e0361cfe97 (patch) | |
tree | d046c6bdc3381e34ffda41ad0116f514e290c908 /base/tuple.h | |
parent | 81a3756ec760fb2383cd32d445bc8849e0d7d306 (diff) | |
download | chromium_src-302bdc13a9baebb21894673e7674f4e0361cfe97.zip chromium_src-302bdc13a9baebb21894673e7674f4e0361cfe97.tar.gz chromium_src-302bdc13a9baebb21894673e7674f4e0361cfe97.tar.bz2 |
Add example usages and tests to scoped_ptr.h and tuple.h.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1305 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/tuple.h')
-rw-r--r-- | base/tuple.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/base/tuple.h b/base/tuple.h index 08ba1e5..c54b579 100644 --- a/base/tuple.h +++ b/base/tuple.h @@ -2,6 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// A Tuple is a generic templatized container, similar in concept to std::pair. +// There are classes Tuple0 to Tuple5, cooresponding to the number of elements +// it contains. The convenient MakeTuple() function takes 0 to 5 arguments, +// and will construct and return the appropriate Tuple object. The functions +// DispatchToMethod and DispatchToFunction take a function pointer or instance +// and method pointer, and unpack a tuple into arguments to the call. +// +// Tuple elements are copied by value, and stored in the tuple. See the unit +// tests for more details of how/when the values are copied. +// +// Example usage: +// // These two methods of creating a Tuple are identical. +// Tuple2<int, const char*> tuple_a(1, "wee"); +// Tuple2<int, const char*> tuple_b = MakeTuple(1, "wee"); +// +// void SomeFunc(int a, const char* b) { } +// DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee") +// DispatchToFunction( +// &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo") +// +// struct { void SomeMeth(int a, int b, int c) { } } foo; +// DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3)); +// // foo->SomeMeth(1, 2, 3); + #ifndef BASE_TUPLE_H__ #define BASE_TUPLE_H__ |