lmi
[Top][All Lists]
Advanced

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

[lmi] Replacing boost with std C++11 [Was: Fix value_cast defect shown b


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

On 2017-01-09 14:36, Vadim Zeitlin wrote:
> On Mon, 9 Jan 2017 11:20:22 +0000 Greg Chicares <address@hidden> wrote:
[...]
> GC> It seems straightforward to replace is_base_and_derived with is_base_of,
> 
>  Thanks for doing this!

I took a look at other lmi uses of boost, to see whether there's anything
else that's simple and mechanical. The first thing that occurred to me was
enable_if...

> GC> 
> http://stackoverflow.com/questions/28665645/why-is-stdis-base-oft-t-true-when-t-is-a-class-type-but-false-when-t-is-a/28666177#28666177
[...]
>  I'd never have thought that something apparently as simple as is_base_of
> could be so complicated

enable_if shouldn't be very complicated...but maybe it is. The replies
to this question:

http://stackoverflow.com/questions/3111045/where-is-disable-if-in-c0x

discuss writing disable_if in terms of std::enable_if, and I can't tell
at a quick glance whether this was actually difficult. But no matter: we
can just replace disable_if with enable_if with the opposite condition,
AFAICT. What really makes me hesitate here is that, as that stackoverflow
article says,

| std::enable_if is basically boost::enable_if_c, and that there is
| no such thing as boost::enable_if in C++0x.

so using the C++11 feature is a step backward in clarity. However, C++14
adds an enable_if_t that's easier to read, so maybe we should wait.

Similarly, I think we should wait to replace BOOST_STATIC_ASSERT because
C++11's static_assert requires a second argument, which becomes optional
in C++17.

I suppose we might
  s/boost::scoped_ptr/std::unique_ptr/g
  s/boost::shared_ptr/std::shared_ptr/g
and maybe it's also easy to replace these:
  #include <boost/algorithm/minmax_element.hpp>
  #include <boost/cstdint.hpp>




reply via email to

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