Understanding and Maintaining C++ Generic Libraries

Understanding and Maintaining C++ Generic Libraries

UNDERSTANDING AND MAINTAINING C++ GENERIC LIBRARIES A dissertation submitted to Kent State University in partial fulfillment of the requirements for the degree of Doctor of Philosophy by Andrew Sutton August, 2010 Dissertation written by Andrew Sutton B.S., Ohio University, USA, 1999 M.S., Kent State University, USA, 2005 Ph.D., Kent State University, USA, 2010 Approved by Dr. Jonathan Maletic Chair, Doctoral Dissertation Committee Dr. Gwenn Volkert Members, Doctoral Dissertation Committee Dr. Mikhail Nesterenko Dr. Michael Collard Dr. Donna Witter Accepted by Dr. Robert A. Walker Chair, Department of Computer Science Dr. Timothy Moerland Dean, College of Arts and Sciences ii TABLE OF CONTENTS TABLE OF CONTENTS ...............................................................................................III LIST OF FIGURES .....................................................................................................VIII LIST OF TABLES ..................................................................................................... XVII ACKNOWLEDGEMENTS ........................................................................................XIX CHAPTER 1 INTRODUCTION................................................................................... 21 1.1 Research Overview ................................................................................................. 23 1.2 Contributions........................................................................................................... 23 1.3 Broader Impacts ...................................................................................................... 25 1.4 Organization ............................................................................................................ 26 CHAPTER 2 TEMPLATES + CONCEPTS = GENERIC LIBRARIES .................. 28 2.1 Templates ................................................................................................................ 28 2.1.1 Function Templates....................................................................................... 29 2.1.2 Class Templates ............................................................................................ 33 2.1.3 Non-Type and Variadic Template Parameters.............................................. 39 2.2 Concepts.................................................................................................................. 47 2.2.1 Concept Definitions ...................................................................................... 48 2.2.2 Constrained Templates.................................................................................. 53 2.2.3 Concept Checking ......................................................................................... 56 2.2.4 An Alternative Syntax................................................................................... 59 2.3 Generic Libraries..................................................................................................... 60 iii CHAPTER 3 IDIOMS FOR GENERIC PROGRAMMING ..................................... 62 3.1 Functors................................................................................................................... 63 3.2 Type Traits .............................................................................................................. 65 3.3 Traits Classes........................................................................................................... 67 3.4 Tag Classes and Hierarchies ................................................................................... 68 3.5 Tag Dispatch ........................................................................................................... 69 3.6 SFINAE Traps......................................................................................................... 71 3.7 Partial Template Definition..................................................................................... 74 3.8 Concept-Controlled Polymorphism......................................................................... 75 3.9 Template Metaprogramming................................................................................... 77 3.10 Mixins...................................................................................................................... 79 3.11 Curiously Recurring Template Pattern.................................................................... 81 CHAPTER 4 EMULATING CONCEPTS ................................................................... 84 4.1 Emulation Techniques............................................................................................. 84 4.1.1 Automatic Concepts ...................................................................................... 85 4.1.2 Explicit Concepts .......................................................................................... 86 4.1.3 Requiring Operations .................................................................................... 89 4.1.4 Defining Traits .............................................................................................. 89 4.1.5 Refining Concepts......................................................................................... 90 4.1.6 Nesting Requirements ................................................................................... 91 4.1.7 Constraining Templates ................................................................................ 92 4.2 Implementation........................................................................................................ 96 iv 4.3 Discussion ............................................................................................................... 98 4.3.1 The Nature of Concepts ................................................................................ 98 4.3.2 Casual Modeling ........................................................................................... 99 4.4 Conclusions ........................................................................................................... 101 CHAPTER 5 REVERSE ENGINEERING GENERIC SOURCE CODE .............. 103 5.1 Related Work......................................................................................................... 103 5.2 Reverse Engineering Templates and Concepts ..................................................... 105 5.2.1 An Program Model for Templates and Concepts........................................ 105 5.2.2 Implementation ........................................................................................... 110 5.3 Source Code Models for Generic Libraries........................................................... 112 5.3.1 Template Instantiation Graph...................................................................... 113 5.3.2 Constraint Propagation Graph..................................................................... 117 5.3.3 Concept Lattice ........................................................................................... 118 5.4 Conclusions ........................................................................................................... 120 CHAPTER 6 IDIOM USAGE IN GENERIC LIBRARIES ..................................... 121 6.1 Micropatterns for Generic Libraries...................................................................... 121 6.2 Validation.............................................................................................................. 126 6.3 Empirical Study..................................................................................................... 130 6.4 Discussion and Conclusions.................................................................................. 132 CHAPTER 7 A REFERENCE ARCHITECTURE FOR GENERIC LIBRARIES135 7.1 Architectural Description ...................................................................................... 135 7.1.1 Conceptual Elements................................................................................... 138 v 7.1.2 Behavioral Elements ................................................................................... 138 7.1.3 Structural Elements ..................................................................................... 141 7.2 Validation.............................................................................................................. 144 7.3 Conclusions ........................................................................................................... 149 CHAPTER 8 MIGRATING TEMPLATES TO CONCEPTS ................................. 151 8.1 Overview ............................................................................................................... 152 8.2 Approach ............................................................................................................... 154 8.2.1 Requirement Extraction .............................................................................. 155 8.2.2 Concept Matching ....................................................................................... 156 8.2.3 Concept Instantiation .................................................................................. 159 8.2.4 Refinement Search ...................................................................................... 163 8.2.5 Concept Analysis ........................................................................................ 165 8.3 Evaluation.............................................................................................................. 170

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    222 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us