![]() | |
![]() ![]() |
![]() | Imperfect C++ Practical Solutions for Real-Life Programming By Matthew Wilson |
Table of Contents | |
Part Four. Cognizant Conversions |
Chapter 20. Shims
This entire chapter revolves around one rather important imperfection that C++ shares with pretty much any language you can think of, so I'm going to start with the imperfection itself.
Needless to say, this is a pretty bold claim, and a serious problem. The concept of shims described here and the broader concept of explicit generalization supported by it have evolved in two separate threads over several years. Ironically, shims first came about as a result of my naïve irritation with the specification of the std::basic_string template, insofar as it's not providing an implicit conversion operator. Thankfully, I woke up to myself before doing something as heinous as deriving from it and implementing a conversion operator in the derived class.[1] The original shim technique developed to address that case has, through a couple of evolutionary steps, ended up as the c_str_ptr access shim, which we see in section 20.6.1.
The second was a continual frustration over the inconsistencies between so-called smart pointers and their raw pointer equivalents. The technique that has evolved provides a unified syntax for dealing with pointers, whether they are raw, simple, smart, or too-smart-for-their-own-good. |
![]() | |
![]() ![]() |