Utilities for Modern C++

This library includes many useful utilities for C++.

List of utilities

Integration

Downloading libraries

The project will try to find/download the libraries required but it’s much easier to have the libraries installed in advance:

sudo apt-get install libboost-all-dev -y
sudo apt install ocl-icd-libopencl1 opencl-headers clinfo ocl-icd-opencl-dev beignet -y
sudo apt-get install gnuplot-x11 -y

Also make sure you have a modern C++ compiler installed and you’re ready to run all the examples in the project.

Including in CMake

You can include it in your CMake project with:

include(ExternalProject)
ExternalProject_Add(
        utilities
        GIT_REPOSITORY "https://github.com/alandefreitas/utilities.git"
        GIT_TAG "master"
        SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/utilities"
        PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/include/utilities-prefix"
        UPDATE_COMMAND ""
        CONFIGURE_COMMAND ""
        BUILD_COMMAND ""
        INSTALL_COMMAND ""
        TEST_COMMAND ""
)

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/utilities/find_external_packages.cmake)
    include(${CMAKE_CURRENT_SOURCE_DIR}/include/utilities/find_external_packages.cmake)
endif()
# ... create your target
add_executable(my_target main.cpp)
target_link_libraries(my_target ${Utils_LIBRARIES})
target_include_directories(my_target PUBLIC ${Utils_INCLUDE_DIRS})
add_dependencies(my_target utilities)

The external project might need to download some files so run cmake with sudo at least for the first time.

After that, just include utils.h in your source file. All utilities are in the utl namespace. The libraries are organized in such a way that there is no conflict with the std so you can use these namespaces:

using namespace std;
using namespace utl;

However, note that it’s a VERY bad programming practice to do that globally in header files.

Examples

You can look at all examples in the examples directory.

Issues

If you have issues, you can:

Thank you for trying this library. Send me an email for any special considerations.