My Project
DefinesPtrs.h File Reference
#include <memory>
Include dependency graph for DefinesPtrs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define UNITY_DEFINES_PTRS(classname)
 Macro to add smart pointer definitions to a class. More...
 

Macro Definition Documentation

#define UNITY_DEFINES_PTRS (   classname)
Value:
typedef std::shared_ptr<classname> SPtr; \
typedef std::shared_ptr<classname const> SCPtr; \
typedef std::unique_ptr<classname> UPtr; \
typedef std::unique_ptr<classname const> UCPtr

Macro to add smart pointer definitions to a class.

This macro injects type definitions for smart pointer types into a class. It is useful to establish a common naming convention for smart pointers across a project.

You can use the macro as follows. Note that the macro argument is the name of the class being defined.

1 class MyClass
2 {
3 public:
4  UNITY_DEFINES_PTRS(MyClass);
5  // MyClass now provides public typedefs for SPtr, SCPtr, UPtr, and UCPtr.
6  // ...
7 };

Callers of MyClass can now, for example, write

1 MyClass::UPtr p(new MyClass);