C++ is a great programming language that has many useful libraries. One of the most useful libraries are packed in Boost C++ Libraries. which is a set of C++ libraries that contains 164 individual libraries (as of version 1.76) that significantly expand the C++ programming language using template metaprogramming. You can use boost libraries with the most of C++ IDE and compilers.
In this post we will explain what the Boost C++ Libraries are and how you can use them in C++,
Table of Contents
What are the Boost C++ libraries?
Boost is a set of C++ libraries that contains 164 individual libraries (as of version 1.76) that significantly expand the C++ programming language using template metaprogramming. Boost libraries provides methods for the computational tasks and structures such as linear algebra, multithreading, image processing, regular expressions, pseudorandom number generation, and unit testing. Boost has libraries that work well with the C++ Standard Library. Boost works on almost any modern operating systems.
The first Boost was released on 1 September 1999 and now it has 1.81.0 version released in 2022. Boost C++ libraries are designed to allow Boost to be used with both free and proprietary software projects and they are licensed under the Boost Software License.
RAD Studio allows you to install a subset of Boost that has been fully tested and preconfigured specifically for C++Builder. RAD Studio supports different versions of Boost depending on the compiler that you use to build your application:
Boost C++ Library | Platform | Compiler | Boost Version |
Boost Win32 Classic Toolchain Boost Win32 Clang-enhanced Classic Toolchain | 32-bit Windows | BCC32 BCC32C | 1.39.0 1.70.0 |
Boost Win64 Toolchain | 64-bit Windows | BCC64 | 1.70.0 |
What are the Boost C++ libraries for the Win32 classic toolchain in C++ Builder?
The Boost Win32 Classic Toolchain C++ Libraries (version 1.39) are for the classic toolchain for Win32 only C++ Builder applications. If you have older classic C++ Builder 32bit applications that uses classic compiler you need this library. If you want to modernize, you can use Boost 1.70 for the modern Win32 and Win64 Clang-enhanced platforms.
What the Boost C++ libraries for the Win32 Clang-enhanced classic toolchain in C++ Builder?
The Win32 Boost C++ libraries are a set of C++ libraries that significantly expand the language using template metaprogramming. This is for the Win32 Clang-enhanced toolchain only.
What are the Boost C++ libraries for the Win64 toolchain in C++ Builder?
The Win64 Boost C++ libraries are a set of C++ libraries that significantly expand the language using template metaprogramming. This is for the Win64 platform only.
How to install the Boost C++ libraries?
To install Boost, select Tools > GetIt Package Manager, search ‘boost’ and select one of the Boost packages. Click Install to start the process.
How to use Boost C++ libraries – a Console application example
Here is a console application that uses boost::algorithm::apply_permuation()
, If you installed boost library (here is 1.70 installed) more algorithms examples can be found in here “C:\Program Files (x86)\Embarcadero\Studio\22.0\include\boost_1_70\libs\algorithm\example
“
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include <iostream> #include <vector> #include <boost/algorithm/apply_permutation.hpp> int main() { std::vector<int> vec{1, 2, 3, 4, 5}, order{4, 2, 3, 1, 0}; std::cout << "Using apply_permutation() with iterators:\n" ; boost::algorithm::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end()); for (const auto& v : vec) { std::cout << v << "," ; } system("pause"); return 0; } |
How to use Boost C++ libraries – a C++ Builder VCL example
Here is a VCL example that runs boost::algorithm::apply_permuation()
with a button (TButton
) and a memo (TMemo
),
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#include <vcl.h> #include <vector> #include <boost/algorithm/apply_permutation.hpp> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.fmx" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { std::vector<int> vec{1, 2, 3, 4, 5}, order{4, 2, 3, 1, 0}; Memo1->Lines->Add( "Using apply_permutation() with iterators:"); boost::algorithm::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end()); for (const auto& v : vec) { Memo1->Lines->Add( IntToStr( v) ); } } |
How to use Boost C++ libraries – a C++ Builder FMX example
Here is a FMX example that runs boost::algorithm::apply_permuation()
with a button (TButton
) and a memo (TMemo
),
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#include <fmx.h> #include <vector> #include <boost/algorithm/apply_permutation.hpp> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.fmx" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { std::vector<int> vec{1, 2, 3, 4, 5}, order{4, 2, 3, 1, 0}; Memo1->Lines->Add( "Using apply_permutation() with iterators:"); boost::algorithm::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end()); for (const auto& v : vec) { Memo1->Lines->Add( IntToStr( v) ); } } |
Where to find more examples of how to use Boost C++ libraries?
In C++ Builder, If you installed a boost version you will find a folder there in that version (i.e. boost_1_70 folder for the version 1.70);
- Go to the include folder of RAD Studio (i.e.
C:\Program Files (x86)\Embarcadero\Studio\22.0\include
). - Navigate to boost folder there, for example if you installed boost 1.70 it is under “
C:\Program Files (x86)\Embarcadero\Studio\22.0\include\boost_1_70
“ - Goto “libs” folder, there are many documents and examples in each of folder there. For example, you can find algorithm examples in
C:\Program Files (x86)\Embarcadero\Studio\22.0\include\boost_1_70\libs\algorithm\example
You can find more documents and examples about boost library online in;
and the latest version can be downloaded from https://www.boost.org/ or you can use C++ Builder compatible version via https://getitnow.embarcadero.com/?q=boost&product=rad-studio&sub=all&sortby=date&categories=-1
C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.
There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise versions of C++ Builder and there is a trial version you can download from here.
Design. Code. Compile. Deploy.
Start Free Trial
Free C++Builder Community Edition