Book Image

D Cookbook

By : Adam Ruppe
Book Image

D Cookbook

By: Adam Ruppe

Overview of this book

Table of Contents (21 chapters)
D Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 6. Wrapped Types

In this chapter, we will explore D's rich abstraction capabilities to wrap, extend, or constrain other types. We'll learn about:

  • Creating a struct with reference semantics

  • Simulating inheritance with structs

  • Creating a ranged integer

  • Creating an opaque handle type

  • Creating a subtyped string for i18n

  • Forwarding methods with opDispatch

  • Creating a tagged dynamic type

  • Creating a structure with two views into the same data

  • Simulating multiple inheritance with mixin templates