Smart Pointers

Total Page:16

File Type:pdf, Size:1020Kb

Smart Pointers TDDD38 APiC++ Smartpointers 317 Smart pointers A smart pointer stores a pointer to another object. • simplifies resource management – can prevent memory leaks if exceptions are thrown – can help ensure that resources are available as long as they are needed, and disposed of when no longer needed • strong and weak references –astrong reference protects the referenced object from garbage collection – an object referenced only by weak references is considered unreachable and may be collected at any time • C++ provide strong/weak reference functionality for pointers – include <memory> – raw pointers are basically weak, but not true weak, since they don’t know when the referenced object becomes unreachable • shared_ptr (strong) – reference counting smart pointer – the controlled resource is released when the use count (reference count) becomes 0 (unreachable) – supports copy semantics – shared_ptrs may be stored in containers • weak_ptr (weak) – are like raw pointers, but know when they dangle (have expired) • unique_ptr (strong) – supports moving instead of copying File: Standard-Smart-Pointers-OH-en © 2014 Tommy Olsson, IDA, Linköpings universitet (2014-11-13) TDDD38 APiC++ Smartpointers 318 unique_ptr (1) • retains sole ownership of an object through a pointer and destroys that object when the unique_ptr goes out of scope template <class T, class D = default_delete<T>> class unique_ptr { … }; {//some block unique_ptr<Object> up1{ new Object }; // single object version unique_ptr<Object[]> up2{ new Object[10] }; // array version unique_ptr<Object> up3{ up1 }; // error – copy constructor is removed up1 = up3; // error – copy assignment is removed unique_ptr<Object> up4{ std::move(up1) }; // ownership is transferred to up4 up1 = std::move(up4); // ownership is transferred to up1 } • will dispose of the pointed-to object when destroyed itself – for example when leaving block scope – this is done with an associated deleter • typical uses – providing exception safety by deleting dynamically allocated objects on both normal exit and exit through exception – transferring ownership of uniquely-owned objects with dynamic lifetime into functions (argument passing) – acquiring ownership of uniquely-owned objects with dynamic lifetime from functions (return value) – as the element type in move-aware containers, such as std::vector, which hold pointers to dynamically-allocated objects File: Standard-Smart-Pointers-OH-en © 2014 Tommy Olsson, IDA, Linköpings universitet (2014-11-13) TDDD38 APiC++ Smartpointers 319 unique_ptr (2) • constructors unique_ptr<T> up1; // default constructor – up1 owns nothing unique_ptr<T> up2{ nullptr }; // up2 owns nothing unique_ptr<T> up3{ new T }; // taking a pointer to an object – up3 owns the pointed to object unique_ptr<T> up4{ std::move(up3) }; // move constructor – ownership is transferred to up4 unique_ptr<U> up5{ std::move(up4) }; // type converting constructor – ownership is transferred – there is also a constructor for passing an auto_ptr smart pointer (C++98, deprecated in C++11) – there are also versions taking a deleter • destructor – deletes the owned object • assignment up1 = std::move(up2); // move assignment – up2 becomes nullpointer up1 = nullptr;//becomes as if default initialized up1 = std::move(up5); // type converting assignment, also the deleter will be converted File: Standard-Smart-Pointers-OH-en © 2014 Tommy Olsson, IDA, Linköpings universitet (2014-11-13) TDDD38 APiC++ Smartpointers 320 unique_ptr (3) • observers cout << *up << endl; // up must not be nullptr cout << up->memfun() << endl; // up must not be nullptr cout << up.get()->memfun() << endl; // get() returns the stored pointer cout << up2[i] << endl; // array version elements are indexable if (up) cout << up->memfun() << endl; // true if stored pointer is not nullptr unique_ptr<Object>::deleter_type = get_deleter(); • modifiers Object* p{ up.release() }; // sets up to nullptr up.reset(p); // assigns new pointer, and then calls the deleter for the old pointer, if not nullptr up1.swap(up2); // swaps pointers and deleters – also non-member version up.reset(new int(2)) // assigns new pointer, and then calls the deleter for the old pointer • comparisons – memory locations compared == != < <= > >= File: Standard-Smart-Pointers-OH-en © 2014 Tommy Olsson, IDA, Linköpings universitet (2014-11-13) TDDD38 APiC++ Smartpointers 321 Standard library default deleters • the single object deleter calls delete on the stored pointer – defined as primary template template <typename T> struct default_delete { constexpr default_delete() noexcept = default; template <typename U> default_delete(const default_delete<U>&) noexcept; void operator()(T* ptr) const { static_assert(sizeof(T) > 0, "can’t delete pointer to incomplete type"); delete ptr; } }; • the array deleter is declared as an explicit specialization, which calls delete[] on the stored pointer template <typename T> struct default_delete<T[]> { constexpr default_delete() noexcept = default; void operator()(T* ptr) const { static_assert(sizeof(T) > 0, "can’t delete pointer to incomplete type"); delete[] ptr; } template <typename U> void operator()(U*) const = delete; }; File: Standard-Smart-Pointers-OH-en © 2014 Tommy Olsson, IDA, Linköpings universitet (2014-11-13) TDDD38 APiC++ Smartpointers 322 Shared-ownership pointers • Implements semantics of shared ownership – stores a pointer, usually obtained via new – the last remaining owner of the pointer is responsible for destroying the object, or – otherwise releasing the resources associated with the stored pointer • Two associated smart pointer types – shared_ptr – weak_ptr File: Standard-Smart-Pointers-OH-en © 2014 Tommy Olsson, IDA, Linköpings universitet (2014-11-13) TDDD38 APiC++ Smartpointers 323 shared_ptr • a shared_ptr object can take ownership of a pointer and manage the storage of that pointer shared_ptr<int> sp1{ new int{ 17 } }; // use count is set to 1 – provide a limited garbage-collection facility • shared_ptr objects can share ownership shared_ptr<int> sp2{ sp1 }; // use count is increased to 2 – the group of owners becomes responsible to delete the pointer when the last of them releases ownership • shared_ptr objects can only share ownership by copying their values – two shared_ptr objects constructed from the same (non-shared) pointer will both own the pointer without sharing it int* p = new int{ 4711 }; shared_ptr<int> sp3{ p }; // use count is set to 1 shared_ptr<int> sp4{ p }; // use count is set to 1 – if one such shared_ptr releases the pointer, deleting the managed object, leaves the other pointing to an invalid location • ownership is released as soon as a shared pointer object is – destroyed – changed by an assignment – changed by a call to reset() if the use count is 1 when this happens, the managed pointer is deleted File: Standard-Smart-Pointers-OH-en © 2014 Tommy Olsson, IDA, Linköpings universitet (2014-11-13) TDDD38 APiC++ Smartpointers 324 Inside shared_ptr shared_ptr object control block (on heap) use count: 1 (strong count) weak count: 0 (on heap) • if several shared_ptr shares ownership of object they will also share the control block – use count (strong count) stores the number of strong references, i.e. shared_ptr, referring to object – weak count stores the number of weak references, i.e. weak_ptr, referring to object (none above) File: Standard-Smart-Pointers-OH-en © 2014 Tommy Olsson, IDA, Linköpings universitet (2014-11-13) TDDD38 APiC++ Smartpointers 325 shared_ptr operations (1) • constructors shared_ptr<int> sp1; // default constructor – sp1 is empty, use count of zero shared_ptr<int> sp2{ nullptr }; // from null pointer – same as default construction shared_ptr<int> sp3{ new int{17} }; // from pointer – sp3 owns the pointer, use count is set to 1 shared_ptr<int> sp4{ sp3 }; // copy constructor – if sp3 is not empty ownership is shared shared_ptr<int> sp5{ std::move(sp3) }; // move constructor – sp3 becomes empty, as if default-constructed shared_ptr<int> sp6{ wp }; // copy from weak_ptr – bad_weak_ptr thrown if wp has expired shared_ptr<int> sp7{ up }; // move from unique_ptr, or auto_ptr – aliasing constructor – example later • destructor – if use count is greater than 1, the use count of the other objects sharing ownership is decreased by 1 – if use count is 1 (last referrer) the owned object is deleted – if use count is 0 (empty shared_ptr) the destructor has no side effects File: Standard-Smart-Pointers-OH-en © 2014 Tommy Olsson, IDA, Linköpings universitet (2014-11-13) TDDD38 APiC++ Smartpointers 326 shared_ptr operations (2) • assignment sp1 = sp2; // copy assignment – add sp1 as a shared owner to sp2’s assets sp1 = std::move(sp2); // move assignment – transfer ownership from sp2 to sp1, sp2 becomes empty sp1 = std::move(up); // move from unique_ptr (or auto_ptr) – ownership is transferred, use count set to 1 sp1 = nullptr;//managed pointer is deleted, since use count is 1 – sp1 becomes empty – a call to an assignment operator has the same effect as if the shared_ptr destructor was called before the value is changed, including the deletion of the managed object if use count was 1 (pointer was unique) – the value of a pointer cannot be assigned directly to a shared_ptr object sp1 = std::make_shared<int>(17); // make_shared returns shared_ptr<int> (copy assignment) sp1.reset(new int{ 17 }); – a call to reset() has the same effect as if the shared_ptr destructor was called before the value is changed File: Standard-Smart-Pointers-OH-en © 2014 Tommy Olsson, IDA, Linköpings universitet (2014-11-13)
Recommended publications
  • Garbage Collection for Java Distributed Objects
    GARBAGE COLLECTION FOR JAVA DISTRIBUTED OBJECTS by Andrei A. Dãncus A Thesis Submitted to the Faculty of the WORCESTER POLYTECHNIC INSTITUTE in partial fulfillment of the requirements of the Degree of Master of Science in Computer Science by ____________________________ Andrei A. Dãncus Date: May 2nd, 2001 Approved: ___________________________________ Dr. David Finkel, Advisor ___________________________________ Dr. Mark L. Claypool, Reader ___________________________________ Dr. Micha Hofri, Head of Department Abstract We present a distributed garbage collection algorithm for Java distributed objects using the object model provided by the Java Support for Distributed Objects (JSDA) object model and using weak references in Java. The algorithm can also be used for any other Java based distributed object models that use the stub-skeleton paradigm. Furthermore, the solution could also be applied to any language that supports weak references as a mean of interaction with the local garbage collector. We also give a formal definition and a proof of correctness for the proposed algorithm. i Acknowledgements I would like to express my gratitude to my advisor Dr. David Finkel, for his encouragement and guidance over the last two years. I also want to thank Dr. Mark Claypool for being the reader of this thesis. Thanks to Radu Teodorescu, co-author of the initial JSDA project, for reviewing portions of the JSDA Parser. ii Table of Contents 1. Introduction……………………………………………………………………………1 2. Background and Related Work………………………………………………………3 2.1 Distributed
    [Show full text]
  • Smart Pointers Raw Pointers (1 of 3)
    Data Abstraction & Problem Solving with C++: Walls and Mirrors Seventh Edition C++ Interlude 4 Safe Memory Management Using Smart Pointers Raw Pointers (1 of 3) • Allocate memory in free store by using new operator – Returns reference to newly created object in memory • Store reference to object in a pointer variable – Use pointer variable to access object • Copy reference to another pointer variable – Creates alias to same object Copyright © 2017, 2013, 2007 Pearson Education, Inc. All Rights Reserved Raw Pointers (2 of 3) • Use delete operator to deallocate object’s memory – Must also set to null p t r any pointer variables that referenced the object • Need to keep track number of aliases that reference an object … else results in – Dangling pointers – Memory leaks – Other errors (program crash, wasted memory, …) Copyright © 2017, 2013, 2007 Pearson Education, Inc. All Rights Reserved Raw Pointers (3 of 3) • Languages such as Java and Python disallow direct reference to objects – Use reference counting to track number of aliases that reference an object – Known as the “reference count” • Language can detect when object no longer has references – Can deallocate … known as “garbage collection” Copyright © 2017, 2013, 2007 Pearson Education, Inc. All Rights Reserved Smart Pointers (1 of 2) • C++ now supports “smart” pointers (or managed pointers) – Act like raw pointers – Also provide automatic memory management features • When you declare a smart pointer – Placed on application stack – Smart pointer references an object object is “managed” Copyright © 2017, 2013, 2007 Pearson Education, Inc. All Rights Reserved Smart Pointers (2 of 2) • Smart-pointer templates – shared_p t r – provides shared ownership of object – unique_p t r – no other pointer can reference same object – weak_p t r – reference to an object already managed by a shared pointer … does not have ownership of the object Copyright © 2017, 2013, 2007 Pearson Education, Inc.
    [Show full text]
  • Metaclasses: Generative C++
    Metaclasses: Generative C++ Document Number: P0707 R3 Date: 2018-02-11 Reply-to: Herb Sutter ([email protected]) Audience: SG7, EWG Contents 1 Overview .............................................................................................................................................................2 2 Language: Metaclasses .......................................................................................................................................7 3 Library: Example metaclasses .......................................................................................................................... 18 4 Applying metaclasses: Qt moc and C++/WinRT .............................................................................................. 35 5 Alternatives for sourcedefinition transform syntax .................................................................................... 41 6 Alternatives for applying the transform .......................................................................................................... 43 7 FAQs ................................................................................................................................................................. 46 8 Revision history ............................................................................................................................................... 51 Major changes in R3: Switched to function-style declaration syntax per SG7 direction in Albuquerque (old: $class M new: constexpr void M(meta::type target,
    [Show full text]
  • Garbage Collection in Object Oriented Databases Using
    Garbage Collection in Ob ject Or iente d Databas e s Us ing Transactional Cyclic Reference Counting S Ashwin Prasan Roy S Se shadr i Avi Silb erschatz S Sudarshan 1 2 Indian Institute of Technology Bell Lab orator ie s Mumbai India Murray Hill NJ sashwincswi sce du avib elllabscom fprasans e shadr isudarshagcs eiitber netin Intro duction Ob ject or iente d databas e s OODBs unlike relational Ab stract databas e s supp ort the notion of ob ject identity and ob jects can refer to other ob jects via ob ject identi ers Requir ing the programmer to wr ite co de to track Garbage collection i s imp ortant in ob ject ob jects and the ir reference s and to delete ob jects that or iente d databas e s to f ree the programmer are no longer reference d i s error prone and leads to f rom explicitly deallo cating memory In thi s common programming errors such as memory leaks pap er we pre s ent a garbage collection al garbage ob jects that are not referre d to f rom any gor ithm calle d Transactional Cyclic Refer where and havent b een delete d and dangling ref ence Counting TCRC for ob ject or iente d erence s While the s e problems are pre s ent in tradi databas e s The algor ithm i s bas e d on a var i tional programming language s the eect of a memory ant of a reference counting algor ithm pro leak i s limite d to individual runs of programs s ince p os e d for functional programming language s all garbage i s implicitly collecte d when the program The algor ithm keeps track of auxiliary refer terminate s The problem b ecome s more s
    [Show full text]
  • Transparent Garbage Collection for C++
    Document Number: WG21/N1833=05-0093 Date: 2005-06-24 Reply to: Hans-J. Boehm [email protected] 1501 Page Mill Rd., MS 1138 Palo Alto CA 94304 USA Transparent Garbage Collection for C++ Hans Boehm Michael Spertus Abstract A number of possible approaches to automatic memory management in C++ have been considered over the years. Here we propose the re- consideration of an approach that relies on partially conservative garbage collection. Its principal advantage is that objects referenced by ordinary pointers may be garbage-collected. Unlike other approaches, this makes it possible to garbage-collect ob- jects allocated and manipulated by most legacy libraries. This makes it much easier to convert existing code to a garbage-collected environment. It also means that it can be used, for example, to “repair” legacy code with deficient memory management. The approach taken here is similar to that taken by Bjarne Strous- trup’s much earlier proposal (N0932=96-0114). Based on prior discussion on the core reflector, this version does insist that implementations make an attempt at garbage collection if so requested by the application. How- ever, since there is no real notion of space usage in the standard, there is no way to make this a substantive requirement. An implementation that “garbage collects” by deallocating all collectable memory at process exit will remain conforming, though it is likely to be unsatisfactory for some uses. 1 Introduction A number of different mechanisms for adding automatic memory reclamation (garbage collection) to C++ have been considered: 1. Smart-pointer-based approaches which recycle objects no longer ref- erenced via special library-defined replacement pointer types.
    [Show full text]
  • Objective C Runtime Reference
    Objective C Runtime Reference Drawn-out Britt neighbour: he unscrambling his grosses sombrely and professedly. Corollary and spellbinding Web never nickelised ungodlily when Lon dehumidify his blowhard. Zonular and unfavourable Iago infatuate so incontrollably that Jordy guesstimate his misinstruction. Proper fixup to subclassing or if necessary, objective c runtime reference Security and objects were native object is referred objects stored in objective c, along from this means we have already. Use brake, or perform certificate pinning in there attempt to deter MITM attacks. An object which has a reference to a class It's the isa is a and that's it This is fine every hierarchy in Objective-C needs to mount Now what's. Use direct access control the man page. This function allows us to voluntary a reference on every self object. The exception handling code uses a header file implementing the generic parts of the Itanium EH ABI. If the method is almost in the cache, thanks to Medium Members. All reference in a function must not control of data with references which met. Understanding the Objective-C Runtime Logo Table Of Contents. Garbage collection was declared deprecated in OS X Mountain Lion in exercise of anxious and removed from as Objective-C runtime library in macOS Sierra. Objective-C Runtime Reference. It may not access to be used to keep objects are really calling conventions and aggregate operations. Thank has for putting so in effort than your posts. This will cut down on the alien of Objective C runtime information. Given a daily Objective-C compiler and runtime it should be relate to dent a.
    [Show full text]
  • Smart Pointer Demo Goals Time
    Outline Smart Pointer Demo Goals Time CPSC 427: Object-Oriented Programming Michael J. Fischer Lecture 13 March 3, 2016 CPSC 427, Lecture 13 1/17 Outline Smart Pointer Demo Goals Time Smart Pointer Demo More on Course Goals Clocks and Time Measurement CPSC 427, Lecture 13 2/17 Outline Smart Pointer Demo Goals Time Smart Pointer Demo CPSC 427, Lecture 13 3/17 Outline Smart Pointer Demo Goals Time Dangling pointers Pointers can be used to permit object sharing from different contexts. One can have a single object of some type T with many pointers in different contexts that all point to that object. CPSC 427, Lecture 13 4/17 Outline Smart Pointer Demo Goals Time Problems with shared objects If the different contexts have different lifetimes, the problem is to know when it is safe to delete the object. It can be difficult to know when an object should be deleted. Failure to delete an object will cause memory leaks. If the object is deleted while there are still points pointing to it, then those pointers become invalid. We call these dangling pointers. Failure to delete or premature deletion of objects are common sources of errors in C++. CPSC 427, Lecture 13 5/17 Outline Smart Pointer Demo Goals Time Avoiding dangling pointers There are several ways to avoid dangling pointers. 1. Have a top-level manager whose lifetime exceeds that of all of the pointers take responsibility for deleting the objects. 2. Use a garbage collection. (This is java's approach.) 3. Use reference counts. That is, keep track somehow of the number of outstanding pointers to an object.
    [Show full text]
  • C++/CLI Tutorial
    CC++++//CCLLII TTuuttoorriiaall Author: Adam Sawicki, [email protected], www.asawicki.info Version 1.0, December 2011 Table of Contents Table of Contents .............................................................................................................................................................. 1 Introduction ...................................................................................................................................................................... 2 What is C++/CLI? ............................................................................................................................................................... 2 Why Use C++/CLI? ......................................................................................................................................................... 2 What C++/CLI is Not? .................................................................................................................................................... 2 Hello World Example ........................................................................................................................................................ 3 Project Properties ............................................................................................................................................................. 3 Namespaces .....................................................................................................................................................................
    [Show full text]
  • An Evolutionary Study of Linux Memory Management for Fun and Profit Jian Huang, Moinuddin K
    An Evolutionary Study of Linux Memory Management for Fun and Profit Jian Huang, Moinuddin K. Qureshi, and Karsten Schwan, Georgia Institute of Technology https://www.usenix.org/conference/atc16/technical-sessions/presentation/huang This paper is included in the Proceedings of the 2016 USENIX Annual Technical Conference (USENIX ATC ’16). June 22–24, 2016 • Denver, CO, USA 978-1-931971-30-0 Open access to the Proceedings of the 2016 USENIX Annual Technical Conference (USENIX ATC ’16) is sponsored by USENIX. An Evolutionary Study of inu emory anagement for Fun and rofit Jian Huang, Moinuddin K. ureshi, Karsten Schwan Georgia Institute of Technology Astract the patches committed over the last five years from 2009 to 2015. The study covers 4587 patches across Linux We present a comprehensive and uantitative study on versions from 2.6.32.1 to 4.0-rc4. We manually label the development of the Linux memory manager. The each patch after carefully checking the patch, its descrip- study examines 4587 committed patches over the last tions, and follow-up discussions posted by developers. five years (2009-2015) since Linux version 2.6.32. In- To further understand patch distribution over memory se- sights derived from this study concern the development mantics, we build a tool called MChecker to identify the process of the virtual memory system, including its patch changes to the key functions in mm. MChecker matches distribution and patterns, and techniues for memory op- the patches with the source code to track the hot func- timizations and semantics. Specifically, we find that tions that have been updated intensively.
    [Show full text]
  • Memory Management
    Memory management The memory of a computer is a finite resource. Typical Memory programs use a lot of memory over their lifetime, but not all of it at the same time. The aim of memory management is to use that finite management resource as efficiently as possible, according to some criterion. Advanced Compiler Construction In general, programs dynamically allocate memory from two different areas: the stack and the heap. Since the Michel Schinz — 2014–04–10 management of the stack is trivial, the term memory management usually designates that of the heap. 1 2 The memory manager Explicit deallocation The memory manager is the part of the run time system in Explicit memory deallocation presents several problems: charge of managing heap memory. 1. memory can be freed too early, which leads to Its job consists in maintaining the set of free memory blocks dangling pointers — and then to data corruption, (also called objects later) and to use them to fulfill allocation crashes, security issues, etc. requests from the program. 2. memory can be freed too late — or never — which leads Memory deallocation can be either explicit or implicit: to space leaks. – it is explicit when the program asks for a block to be Due to these problems, most modern programming freed, languages are designed to provide implicit deallocation, – it is implicit when the memory manager automatically also called automatic memory management — or garbage tries to free unused blocks when it does not have collection, even though garbage collection refers to a enough free memory to satisfy an allocation request. specific kind of automatic memory management.
    [Show full text]
  • Programming Language Concepts Memory Management in Different
    Programming Language Concepts Memory management in different languages Janyl Jumadinova 13 April, 2017 I Use external software, such as the Boehm-Demers-Weiser collector (a.k.a. Boehm GC), to do garbage collection in C/C++: { use Boehm instead of traditional malloc and free in C http://hboehm.info/gc/ C I Memory management is typically manual: { the standard library functions for memory management in C, malloc and free, have become almost synonymous with manual memory management. 2/16 C I Memory management is typically manual: { the standard library functions for memory management in C, malloc and free, have become almost synonymous with manual memory management. I Use external software, such as the Boehm-Demers-Weiser collector (a.k.a. Boehm GC), to do garbage collection in C/C++: { use Boehm instead of traditional malloc and free in C http://hboehm.info/gc/ 2/16 I In addition to Boehm, we can use smart pointers as a memory management solution. C++ I The standard library functions for memory management in C++ are new and delete. I The higher abstraction level of C++ makes the bookkeeping required for manual memory management even harder than C. 3/16 C++ I The standard library functions for memory management in C++ are new and delete. I The higher abstraction level of C++ makes the bookkeeping required for manual memory management even harder than C. I In addition to Boehm, we can use smart pointers as a memory management solution. 3/16 Smart pointer: // declare a smart pointer on stack // and pass it the raw pointer SomeSmartPtr<MyObject> ptr(new MyObject()); ptr->DoSomething(); // use the object in some way // destruction of the object happens automatically C++ Raw pointer: MyClass *ptr = new MyClass(); ptr->doSomething(); delete ptr; // destroy the object.
    [Show full text]
  • These Aren't the COM Objects You're Looking For
    These Aren't the COM Objects You're Looking For November, 2018 Victor Ciura Technical Lead, Advanced Installer www.advancedinstaller.com Abstract Windows COM is 25 years old. Yet it is relevant today more than ever, because Microsoft has bet its entire modern WinRT API on it (starting with Windows 8/10). But, if you’re familiar with the “old” COM with its idioms and SDK helper classes, you’re in for a treat. With the advent of modern C++ 17, using COM objects and new Windows APIs in your applications feels like a completely new experience. In this session, we’ll explore how using modern C++ features can radically transform the shape of your COM code. By eliminating a lot of boilerplate, your code will be much more readable and maintainable. Classic COM idioms around activation and QueryInterface() can feel totally different with modern C++ helpers. A beautiful example of modern COM usage is C++/WinRT (now part of Windows SDK). This is a standard C++ language projection for the new Windows Runtime API. COM memory management, data marshalling, string handling can all feel quite mechanical in nature and very error prone, so a little help from modern C++ facilities would be more than welcomed. Error handling and debugging can be cumbersome for COM like APIs; we’ll explore some tricks to improve this experience, as well. 2018 Victor Ciura | @ciura_victor !X These Aren't the COM Objects You're Looking For ⚙ Part 1 of N 2018 Victor Ciura | @ciura_victor !2 Why COM ? Why are we talking about this ? Have we really exhausted all the cool C++ template<> topics � ? 2018 Victor Ciura | @ciura_victor !3 Who Am I ? Advanced Installer Clang Power Tools @ciura_victor 2018 Victor Ciura | @ciura_victor !4 How many of you have done any COM programming in the last 20 years ? �$ 2018 Victor Ciura | @ciura_victor !5 How many of you are doing COM programming currently (this year) ? #$ 2018 Victor Ciura | @ciura_victor !6 Let's start using COM..
    [Show full text]