1

In the proxy section the Design Patter from the Gang of Four says:

Overloading the member access operator isn't a good solution for every kind of proxy. Some proxies need to know precisely which operation is called, and overloading the member access operator doesn't work in those cases.

[...]

In that case we must manually implement each proxy operation that forwards the request to the subject.

[...]

Typically all operations verify that the request is legal, that the original object exists, etc., before forwarding the request to the subject. It's tedious to write this code again and again. So it's common to use a preprocessor to generate it automatically.

OK, which preprocessor and how in C++?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Ruggero Turra
  • 16,929
  • 16
  • 85
  • 141

2 Answers2

0

The canonical reference for implementing some Design Patterns in C++ is

Modern C++ Design by Alexandrescu

Another good reference for the techniques of using the type system of C++ for building design patterns is the book on

C++ Templates by Vandevoorde & Josuttis

And the reference for template meta-programming is

C++ Template Metaprogramming: Concepts, Tools and Techniques from Boost and Beyond by David Abrahams and Alesky Gurtovoy.

Andy Finkenstadt
  • 3,547
  • 1
  • 21
  • 25
0

I think they mean automated generation of the wrapper code around the subject class. An example would be wrapper code generated by the SWIG project.

StackedCrooked
  • 34,653
  • 44
  • 154
  • 278