NTB++ is a cross-platform header-only utility library for C++ >= 17.
It includes Colors, Templates & Types.
Useful for printing colors, std::map and std::vector into std::cout.
A couple of common typealiases (typedefs) like String, UInt, StringMap, StringMapOf<Type> are included as well.
Motivation:
We developed this lib as part of a program for a customer,
and we figured it might benefit other developers too.
usingnamespaceNtb;Exposes the following namespaces:
namespaceNtb::Types
namespaceNtb::Templates
namespaceNtb::ColorsusingnamespaceNtb::Types;Exposes the following types:
using Bool
using Char
using UChar
using Short
using UShort
using Int
using UInt
using Long
using LongLong
using ULong
using ULongLong
using String
using MapOf<Type,Type2>
using StringMapOf<Type>
using StringMap
using Vector<Type>usingnamespaceNtb::Templates;Exposes the following templates:
/** * Overloads the '<<' cout operator to recognize vectors. * * @param The vector of type <T>. * @return ostream.*/
std::ostream &operator<<(std::ostream &os, const Vector<T> &v)
/** * Overloads the '<<' cout operator to recognize maps. * * Prints a newline for all elements but the last. * * @param The map of type <T,U>. * @return ostream.*/
std::ostream &operator<<(std::ostream &os, const MapOf<T,U> &v)
Ntb::Templatesmakes use ofNtb::Typesand exposes it.
usingnamespaceNtb::Colors;Exposes the following utilities for coloring std::cout output:
enum Colors : const UInt
/** Color helpers (optional) */const UInt Colors::RESETconst UInt Colors::BLACKconst UInt Colors::REDconst UInt Colors::GREENconst UInt Colors::YELLOWconst UInt Colors::BLUEconst UInt Colors::MAGENTAconst UInt Colors::CYANconst UInt Colors::WHITE/** * Color marker for foreground/background. * * @param color The color code. * @return String with color marker.*/const String col(const UInt color = Colors::RESET)
/** * Color marker for foreground, background and text. * * @param str The input text. * @param front The foreground color code. * @param back The background color code. * @return Encapsulated string with color markers.*/const String col(const String str, const UInt front, const UInt back = Colors::RESET)
Ntb::Colorsmakes use ofNtb::Typesand exposes it.
Min Std: C++17
(structured bindings, inline, nested namespaces)
Tested against OS:
- Linux 4.14.154 Ubuntu 18.04.4 LTS x86_64 (Bionic Beaver)
- Ubuntu 24.04.3
- Windows 7 Home Premium SP1 64 bit
- Windows 10 Home/Pro
- Windows Server 2025 (10.0.26100)
- macOS 15.6.1 (24G90)
Tested against Compiler:
- Clang 9.0.0+
- MSVC 14.28.29910
- MSVC 19.28.29914
- MSVC 19.44.35217
- AppleClang 17.0.0
- GCC 13.3.0
You can use cmake to install the include files.
cd ntbpp
mkdir build && cd build
cmake ..
make install
Include files will be placed into: ${CMAKE_INSTALL_PREFIX}/include/notixbit/ntbpp
You can use vcpkg, git clone or git submodule to install this library.
vcpkg-configuration.json
{
"default-registry": {
//..... redacted
},
"registries": [
{
"kind": "git",
"repository": "https://github.com/notixbit/vcpkg-registry",
"baseline": "c4f78a946944d1a51e89bde41cd61b0460eb6a60",
"packages": [ "ntbpp" ]
}
]
}
Run: vcpkg add port ntbpp
git clone <url>
git submodule add <url>
Unit Testing Framework: CTest
make all test
#include<notixbit.h>usingnamespaceNtb::Colors;
std::cout << col("Notixbit Creative", Colors::WHITE, Colors::RED) << std::endl << std::endl << col("====POLICE==LINE==DO==NOT==CROSS====", Colors::BLACK, Colors::YELLOW) << std::endl << std::endl;Result:
You're very welcome and free to contribute. Thank you.
