This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
typeFunctions.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_BASE_TF_TYPE_FUNCTIONS_H
8#define PXR_BASE_TF_TYPE_FUNCTIONS_H
9
12
13#include "pxr/pxr.h"
14
15#include <memory>
16
17PXR_NAMESPACE_OPEN_SCOPE
18
36template <class T, class ENABLE = void>
38#if 0
39 static T* GetRawPtr(T& t) {
40 return &t;
41 }
42#endif
43
44 static const T* GetRawPtr(const T& t) {
45 return &t;
46 }
47
48 static T& ConstructFromRawPtr(T* ptr) { return *ptr; }
49
50 static bool IsNull(const T&) {
51 return false;
52 }
53
54 static void Class_Object_MUST_Not_Be_Const() { }
55 static void Object_CANNOT_Be_a_Pointer() { }
56};
57
58template <class T>
59struct TfTypeFunctions<T*> {
60 static T* GetRawPtr(T* t) {
61 return t;
62 }
63
64 static T* ConstructFromRawPtr(T* ptr) { return ptr; }
65
66 static bool IsNull(T* ptr) {
67 return !ptr;
68 }
69
70 static void Class_Object_MUST_Be_Passed_By_Address() { }
71 static void Class_Object_MUST_Not_Be_Const() { }
72};
73
74template <class T>
75struct TfTypeFunctions<const T*> {
76 static const T* GetRawPtr(const T* t) {
77 return t;
78 }
79
80 static bool IsNull(const T* ptr) {
81 return !ptr;
82 }
83
84 static const T* ConstructFromRawPtr(T* ptr) { return ptr; }
85 static void Class_Object_MUST_Be_Passed_By_Address() { }
86};
87
88PXR_NAMESPACE_CLOSE_SCOPE
89
90#endif // PXR_BASE_TF_TYPE_FUNCTIONS_H
Implements assorted functions based on compile-time type information.
Definition: typeFunctions.h:37