Changeset dafe9e1 for src/include


Ignore:
Timestamp:
Jun 3, 2019, 1:29:56 PM (5 years ago)
Author:
Andrew Beach <ajbeach@…>
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:
4ae2364
Parents:
a935892
Message:

Fixed broken destructor cycles. Cleaned up strict_dynamic_cast.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/include/cassert

    ra935892 rdafe9e1  
    1010// Created On       : Thu Aug 18 13:19:26 2016
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu May 23 15:30:00 2017
    13 // Update Count     : 17
     12// Last Modified On : Mon Jun  3 13:11:00 2017
     13// Update Count     : 18
    1414//
    1515
     
    4343#endif
    4444
    45 enum StrictAllowNull {NonNull, AllowNull};
    46 
    47 template<typename T, StrictAllowNull nullable = NonNull, typename U>
     45template<typename T, typename U>
    4846static inline T strict_dynamic_cast( const U & src ) {
    49         if (nullable == AllowNull && src == nullptr) {
    50                 return nullptr;
    51         }
    5247        assert(src);
    5348        T ret = dynamic_cast<T>(src);
    5449        assertf(ret, "%s", toString(src).c_str());
    5550        return ret;
     51}
     52
     53template<typename T, decltype(nullptr) null, typename U>
     54static inline T strict_dynamic_cast( const U & src ) {
     55        return src ? strict_dynamic_cast<T, U>( src ) : nullptr;
    5656}
    5757
Note: See TracChangeset for help on using the changeset viewer.