What can Boost do that modern C++ cannot? [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Considering latest modern C++, so C++17, are there any features that Boost has that are not available in modern C++?
In other words: is there anything you cannot accomplish (with a reasonable solution) with modern C++ for which you need to include Boost as a dependency in your project?
Can you please provide a list of such features, that are in Boost and NOT in modern C++17?
And what about C++11 and C++14?

Boost has a wide variety of libraries most of which haven't been incorporated into the standard library. They include but are not limited to:
Networking and other inter process communication
Linear algebra
Serialisation
Parsing
Signals & Slots
much more...
Furthermore, using Boost for features that are in
C++17 gives you some compatibility to older compilers.

Date libraries (over which there would be too much of a disagreement to be in the C++ standard - look at the mess in Java), Boost Spirit, multiprecision, and linear algebra libraries are things that are not in the C++ standard.
Plus a definition of pi (although we finally get one of those in C++20).
Because many feature in Boost eventually make themselves into the standard (std::regex, std::unique_ptr, std::thread, std::unordered_map) with minimal changes, Boost is well-worth sticking with.

Related

How to read/interrogate a filesystem and file structure [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
As a first time programming using vi with a raw Linux terminal in C++, what is the simplest way to recurse through a filesystem and get results such as file size, date, directory date etc?
I imagine I'm missing a library or two that would handle this pretty cleanly which would be great to know. Even better would be knowing where to find a solid reference for the basics like this.
If you have a modern compiler you can use std::filesystem:
https://en.cppreference.com/w/cpp/filesystem
Otherwise you can use boost::filesystem, which is very similar but non standard:
https://www.boost.org/doc/libs/1_67_0/libs/filesystem/doc/index.htm
Boost is a collection of libraries with various purposes and a focus on quality. Boost libraries regularly end up in the new C++ standards so it's good thing to learn.
You might consider (on Linux at least) to use nftw(3). You could use opendir(3) + readdir(3) + closedir with stat(2) (and nftw is using all these). See also syscalls(2) (and read some Linux programming book, perhaps the old ALP). Notice that on Linux (and POSIX systems), the operating system API is in C, not in C++.
Of course, you might use the C++ functions given in f4's answer (they are are based on functions above).
And you could use C++ frameworks such as boost, poco, Qt (also using the functions above).

Best practice: should I use std::thread, Boost, or native calls? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Whats best practice to use: std::thread, native calls, or some library? Is std::thread a 'don't-actually-use-this' convenience, or should it be used whenever threading is needed? Before c++11 came around, it looked like some threading library was best for portability, but now that std::thread is a thing...
What should be used - in terms of industry-standard - in major projects now?
Rule of thumb:
If something has been in the standard library for > X years, use it unless you know it won't fit your needs.
If something has been in the standard library for <= X years, and you're writing non-critical code: Same as before - use it.
Otherwise:
Look for how it got into the standard library (often: Boost);
Snoop around for discussions mentioning both of them, posts by authors, etc.;
Map feature set / design decision differences;
if you still don't have enough information to make a decision, ask here.
In your case, see:
C++ 11 Thread vs Boost Thread is there any difference?
where you'll notice Boost threads have some features not in the standard. If you need those, use the Boost threads, otherwise use std::thread.
There is no one answer to rule them all.
TL;DR It depends
If you want best performance(maybe one of the reasons you are using c++) use native calls. You have full control and no overhead from wrapper classes and checks.
If you need portability and support of c++11 is present the implementation in std is a good choice. Most of the time this option would be the easiest to start with and have most resources available.
Currently the boost duplicates the features of the standard. But it is still viable option if a compiler does not support c++11. In the latest few revisions same boost features are copied directly in the standard.(smart pointers for example)

How to add c++ experimental library to mac compiler? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to add experimental library to mac os x.
http://en.cppreference.com/w/cpp/experimental
how can i add this ?
There is no "experimental" library.
All of the C++ technical specifications that add to the standard library put their definitions into the std::experimental namespace. So std::experimental::future comes from the Concurrency TS. That TS effectively defines a few new functions in std::future, but it does so essentially by creating a new type in a new namespace with the old functions plus a few new ones. Should the TS be incorporated into the standard proper, those features will be added directly to std::future.
These technical specifications are effectively optional features that your standard library implementation may or may not support. If it does not support them, you may find libraries that provide the TS's functionality. For example, the FileSystem TS was based on Boost.Filesystem.
But there is no one thing you can download which will ensure that you will have all of the stuff in std::experimental.

C++ Iterating through files in a directory: Is it bad practice? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
The question has been asked many times here: "How do I iterate through files in a directory in c++?"
I've seen the responses, typically suggesting to use an external library (usually boost filesystem) to handle this and the OS differences in implementation.
My question is: why? Why is this so difficult?
I'm new to the language and can't help but feel that I'm trying to overstep the bounds of idiomatic c++.
Is it more appropriate to implement a single file solution and use another language to implement the file iteration?
Relative to other languages, C++ has a tiny standard library. This has its advantages (porting C++ to a new platform is much easier), but it also means that, to get a lot of things done, you're going to rely on external libraries.
Filesystem work has not, until C++17, been something that has been a part of the C++ standard. And even now, some people are resistant to the C++17 filesystem library because it doesn't work quite so well with certain types of underlying filesystems.
Note that many languages that have standard filesystem support don't support these platforms at all.
I'm new to the language and can't help but feel that I'm trying to overstep the bounds of idiomatic c++.
If you're going to use C++, then you need to accept that you're going to have to go out and use other libraries for a lot of the stuff that many other languages give you for free. Using a library is how you get things done in C++; it's not "overstepping the bounds" of anything.
You can't iterate the files in a directory in C++ without using platform-specific APIs. The core C++ language and the standard library do not provide any mechanism to obtain a directory listing and iterate through it. So in order to do this, you must use an external library or platform specific API.

Why do almost all of the C++ standard libraries not portable (including those of clang, gcc, and vc++)? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I failed to compile gcc's C++ standard library with VC++, and vice versa.
Why do almost all of the C++ standard libraries not portable (including those of clang, gcc, and vc++)?
I also tried STLport, however, it is too old to support C++11.
I'm writing my own mini-STL for embedded systems, where I cannot use the compiler-provided STL because of its non-portability. So, I must care this.
Is there an implementation of the portable C++ standard library?
Part of the standard library's job is to provide portable wrappers around platform-dependent and compiler-dependent functionality. It cannot be fully portable.
There's also no reason why it should be portable. There's no need for it. It is supplied as part of the compiler toolchain. When you have a compiler, you also have a standard library implementation that works with that compiler. No matter which compiler you're using, you already have an implementation of the standard library.