boostorg / lockfree

Boost.Lockfree
125 stars 86 forks source link

change constructor (queue()) has_capacity assert to static assert #43

Closed bansalnvn closed 6 years ago

bansalnvn commented 6 years ago

https://github.com/boostorg/lockfree/blob/ffd91db4589fda2e5f843d0773dc3325baea88e0/include/boost/lockfree/queue.hpp#L188

This check for construction of the queue, if the capacity has been specified as the template parameter should be moved to static assert rather than having the run time assert.

timblechmann commented 6 years ago

iirc this isn't possible, without enable_if tricks, as the static assertion will fire when class is instantiated, not when the class is used. if you find a way, which is not completely ugly, i'm happy to merge a PR, though ...

bansalnvn commented 6 years ago

Yeah, I think currently std::enable_if or the if constexpr is needed. I will close the ticket for now. Thanks.

austin-beer commented 4 years ago

For the record, this is the commit that changed BOOST_STATIC_ASSERT() to BOOST_ASSERT() back in 2012: 505c1c04c18939cfd8fbf58386230ee78f4549ad