Common standalone C++11 utilities.
Cool
is a collection of self-contained headers that provide convenient
utilities missing in the standard library.
Unlike Boost, Cool
's utilities are not meant to
be "usable across a broad spectrum of applications". Instead, each
header brings a zero-configuration solution to common problems. As a result,
Cool
is not as configurable as Boost, however, it intends to be much easier
to use.
Each header file contains a utility:
- cool/ccreate.hpp: wrapper to deal with legacy C data types that need to be created and destroyed.
- cool/colony.hpp: simplified and didactic version of std::colony.
- cool/channel.hpp: Go-like channels.
- cool/compose.hpp: lambda composition (C++17 and above only).
- cool/defer.hpp: deferred execution of statements.
- cool/enum_map.hpp: enumeration map (C++17 and above only).
- cool/indices.hpp: utility to provide safer for loops.
- cool/thread_pool.hpp: Pool of threads with queueable jobs.
The recommended installation of the library is including it as a submodule of your Git project.
In your project, do
$ git submodule add https://github.com/verri/cool.git external/cool
Download the latest release and unzip it.
System-wide installation is recommended only if you are sure about what you doing.
Clone the repository.
$ git clone https://github.com/verri/cool.git
$ cd cool
Install via CMake 3.0+.
$ cmake -H. -Bbuild
$ cmake --build build
$ cmake --install build
Cool
is a header-only library, so you just need to instruct the compiler its location.
Some headers, however, use threads, e.g. channel
and thread_pool
.
Thus, you will probably need to link a thread library as well.
If you installed the library as a submodule, include the following line in your CMakeLists.txt
add_subdirectory(external/cool)
find_package(Threads REQUIRED)
target_link_libraries(my-target PRIVATE cool ${CMAKE_THREAD_LIBS_INIT})
If you installed system-wide, use
find_package(Cool REQUIRED)
find_package(Threads REQUIRED)
target_link_libraries(my-target PRIVATE ${Cool_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
You can directly specify the compiler flags:
$ $CXX -I/path/to/cool/include -std=c++11 -pthreads ...
An incomplete API reference is available here.
Given the simplicity of the libraries, usage examples should suffice.
- cool::ccreate
- cool::colony
- cool::channel
- cool::compose
- cool::defer
- cool::enum_map
- cool::indices
- cool::thread_pool
This project was supported by FAPESP as part of the project "High level data classification based on complex network applied to invariant pattern recognition" (Grant number 2013/25876-6).