[cfe-dev] #ifdef __clang__ guard in AllocatorBase
David Blaikie via cfe-dev
cfe-dev at lists.llvm.org
Wed Feb 3 10:42:05 PST 2016
possible that static_assert isn't supported on some of the compilers we
support, or didn't at some point. I'd check the commit history and if the
reason cited (if there is one) doesn't apply anymore, just remove it.
On Wed, Feb 3, 2016 at 10:16 AM, <Alexander G. Riccio> via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> In Allocator.h, there are two static_asserts that are guarded by an #ifdef
> __clang__. What's up with that? Shouldn't non __clang__ environments be
> able to do this? Surely there's a better way to check for overloads?
>
> The two static_asserts in question:
>
> /// \brief Allocate \a Size bytes of \a Alignment aligned memory. This method
> /// must be implemented by \c DerivedT.
> void *Allocate(size_t Size, size_t Alignment) {#ifdef __clang__
> static_assert(static_cast<void *(AllocatorBase::*)(size_t, size_t)>(
> &AllocatorBase::Allocate) !=
> static_cast<void *(DerivedT::*)(size_t, size_t)>(
> &DerivedT::Allocate),
> "Class derives from AllocatorBase without implementing the "
> "core Allocate(size_t, size_t) overload!");#endif
> return static_cast<DerivedT *>(this)->Allocate(Size, Alignment);
> }
>
> /// \brief Deallocate \a Ptr to \a Size bytes of memory allocated by this
> /// allocator.
> void Deallocate(const void *Ptr, size_t Size) {#ifdef __clang__
> static_assert(static_cast<void (AllocatorBase::*)(const void *, size_t)>(
> &AllocatorBase::Deallocate) !=
> static_cast<void (DerivedT::*)(const void *, size_t)>(
> &DerivedT::Deallocate),
> "Class derives from AllocatorBase without implementing the "
> "core Deallocate(void *) overload!");#endif
> return static_cast<DerivedT *>(this)->Deallocate(Ptr, Size);
> }
>
>
>
> Sincerely,
> Alexander Riccio
> --
> "Change the world or go home."
> about.me/ariccio
>
> <http://about.me/ariccio>
> If left to my own devices, I will build more.
> ⁂
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160203/0f758845/attachment.html>
More information about the cfe-dev
mailing list