lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Replacing boost with std C++11 [Was: Fix value_cast defect sho


From: Greg Chicares
Subject: Re: [lmi] Replacing boost with std C++11 [Was: Fix value_cast defect shown by the unit test]
Date: Wed, 11 Jan 2017 12:48:10 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.5.1

On 2017-01-09 16:49, Vadim Zeitlin wrote:
> On Mon, 9 Jan 2017 16:18:18 +0000 Greg Chicares <address@hidden> wrote:
[...]
> GC> I took a look at other lmi uses of boost, to see whether there's anything
> GC> else that's simple and mechanical. The first thing that occurred to me was
> GC> enable_if...
> 
>  FWIW the first thing that occurred to me was static_assert(), which has
> special compiler support and is just less ugly than BOOST_STATIC_ASSERT.

Modernized now.

commit cbd94a722917b617b2ad72247313bd24e397e5e4

+/// A compile-time failure iff this template is ever instantiated is
+/// desired, but the straightforward
+///   static_assert(0, "");
+/// can fail even if it's never instantiated; instead, it is asserted
+/// that both template parameters are void, which 14.1/7 forbids.

BTW, here's a generic solution:

http://stackoverflow.com/questions/14637356/static-assert-fails-compilation-even-though-template-function-is-called-nowhere/14637534#14637534

| template<typename T>
| struct foobar : std::false_type
| { };
|
| template <typename T>
| inline T getValue(AnObject&)
| {
|     static_assert( foobar<T>::value , "this function has to be implemented 
for desired type");
| }

in case we need it someday, but I couldn't easily find any other place
where we'd want it.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]