Which Boost features overlap with C++11?

前端 未结 2 2115
日久生厌
日久生厌 2020-11-28 00:16

I put my C++ skills on the shelf several years ago and it seems now, when I need them again, the landscape has changed.

We have got C++11 now, and my understanding i

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 00:35

    Replaceable by C++11 language features or libraries

    • Foreach → range-based for
    • Functional/Forward → Perfect forwarding (with rvalue references, variadic templates and std::forward)
    • In Place Factory, Typed In Place Factory → Perfect forwarding (at least for the documented use cases)
    • Lambda → Lambda expression (in non-polymorphic cases)
    • Local function → Lambda expression
    • Min-Max → std::minmax, std::minmax_element
    • Ratio → std::ratio
    • Static Assert → static_assert
    • Thread → , etc (but check this question).
    • Typeof → auto, decltype
    • Value initialized → List-initialization (§8.5.4/3)
    • Math/Special Functions → , see the list below
      • gamma function (tgamma), log gamma function (lgamma)
      • error functions (erf, erfc)
      • log1p, expm1
      • cbrt, hypot
      • acosh, asinh, atanh

    TR1 (they are marked in the documentation if those are TR1 libraries)

    • Array → std::array
    • Bind → std::bind
    • Enable If → std::enable_if
    • Function → std::function
    • Member Function → std::mem_fn
    • Random →
    • Ref → std::ref, std::cref
    • Regex →
    • Result Of → std::result_of
    • Smart Ptr → std::unique_ptr, std::shared_ptr, std::weak_ptr (but boost::intrusive_ptr still cannot be replaced)
    • Swap (swapping arrays) → std::swap
    • Tuple → std::tuple
    • Type Traits →
    • Unordered → ,

    Features back-ported from C++11:

    • Atomic ← std::atomic
    • Chrono ← (see below)
    • Move ← Rvalue references

    Replaceable by C++17 language features:

    • String_ref → std::string_view
    • Filesystem → (Filesystem TS)
    • Optional → std::optional (Library Fundamentals TS v1)
    • Any → std::any (Library Fundamentals TS v1)
    • Math/Special Functions → (Special Math IS), see the list below
      • beta function
      • (normal / associated / spherical) Legendre polynomials
      • (normal / associated) Legendre polynomials
      • Hermite polynomials
      • Bessel (J / Y / I / K) functions (Y is called Neumann function in C++)
      • spherical Bessel (j / y) functions
      • (incomplete / complete) elliptic integrals of (first / second / third kind)
      • Riemann zeta function
      • exponential integral Ei
    • Variant → std::variant (P0088R2)

    The standard team is still working on it:

    • Math Common Factor → std::experimetal::gcd, lcm (Library Fundamentals TS v2)
    • Concept check → Concepts TS
    • Range → Range TS
    • Asio → Networking TS (sockets and timers only)
    • Multiprecision → Numerics TS
    • Coroutine/Coroutine2 → Coroutines TS

    A large part of MPL can be trimmed down or removed using variadic templates. Some common use cases of Lexical cast can be replaced by std::to_string and std::stoX.

    Some Boost libraries are related to C++11 but also have some more extensions, e.g. Boost.Functional/Hash contains hash_combine and related functions not found in C++11, Boost.Chrono has I/O and rounding and many other clocks, etc. so you may still want to take a look at the boost ones before really dismissing them.

提交回复
热议问题