File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -446,6 +446,26 @@ template<typename FromType, typename ToType> struct CopyConstness<const FromType
446446// / @endcond
447447
448448
449+ // //////////////////////////////////////
450+
451+ // / @brief A type-dependent expression that always evaluates to false.
452+ // / This is used as a work-around for the much discussed problem of wanting to do:
453+ // / if constexpr (expr) { }
454+ // / else { static_assert(false); }
455+ // /
456+ // / At present, C++ evaluates static_assert(false) regardless of the outcome of the
457+ // / compile-time expression. By using a type-dependent expression, the static assert
458+ // / is only evaluated during instantiation:
459+ // /
460+ // / static_assert(openvdb::AlwaysFalseValue<T>);
461+ // /
462+ // / This results in the desired outcome of generating a compile-time static assert
463+ // / only if the first clause evaluates to false.
464+
465+ template <class >
466+ inline constexpr bool AlwaysFalseValue = false ;
467+
468+
449469// //////////////////////////////////////
450470
451471
You can’t perform that action at this time.
0 commit comments