Changeset 4ae2364 for src/include/cassert
- Timestamp:
- Jun 3, 2019, 5:36:47 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 98a8290, ee574a2
- Parents:
- f474e91 (diff), dafe9e1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/include/cassert
rf474e91 r4ae2364 10 10 // Created On : Thu Aug 18 13:19:26 2016 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu May 23 15:30:00 201713 // Update Count : 1 712 // Last Modified On : Mon Jun 3 13:11:00 2017 13 // Update Count : 18 14 14 // 15 15 … … 43 43 #endif 44 44 45 enum StrictAllowNull {NonNull, AllowNull}; 46 47 template<typename T, StrictAllowNull nullable = NonNull, typename U> 45 template<typename T, typename U> 48 46 static inline T strict_dynamic_cast( const U & src ) { 49 if (nullable == AllowNull && src == nullptr) {50 return nullptr;51 }52 47 assert(src); 53 48 T ret = dynamic_cast<T>(src); 54 49 assertf(ret, "%s", toString(src).c_str()); 55 50 return ret; 51 } 52 53 template<typename T, decltype(nullptr) null, typename U> 54 static inline T strict_dynamic_cast( const U & src ) { 55 return src ? strict_dynamic_cast<T, U>( src ) : nullptr; 56 56 } 57 57
Note: See TracChangeset
for help on using the changeset viewer.