Quick Start
- Get boost/di.hpp header
wget https://raw.githubusercontent.com/boost-ext/di/cpp14/include/boost/di.hpp
- Include the header and define
di
namespace alias
#include "boost/di.hpp"
namespace di = boost::di;
- Compile with C++14 support
$CXX -std=c++14 ...
Note
[Boost].DI compiles with -fno-exceptions -fno-rtti -Wall -Wextra -Werror -pedantic -pedantic-errors
- To run tests
git clone https://github.com/boost-ext/di && cd di && make
Dependencies
- No external dependencies are required (neither STL nor Boost)
Supported/Tested compilers
Configuration
Macro | Description |
---|---|
BOOST_DI_VERSION |
Current version of [Boost::ext].DI (ex. 1'0'0) |
BOOST_DI_CFG |
Global configuration allows to customize provider and policies (See Config) |
BOOST_DI_CFG_CTOR_LIMIT_SIZE |
Limits number of allowed constructor parameters [0-10, default=10] (See Injections) |
BOOST_DI_CFG_DIAGNOSTICS_LEVEL |
Gives more information with error messages (See Error messages) |
BOOST_DI_NAMESPACE_BEGIN |
namespace boost::inline ext::di::inline v_{version}_{revision}_{patch} { |
BOOST_DI_NAMESPACE_END |
} |
Exception Safety
- [Boost].DI is not using exceptions internally and therefore might be compiled with
-fno-exceptions
. - Check User Guide to verify which API's are marked
noexcept
.
Thread Safety
- [Boost].DI is thread safe.
Error Messages
- [Boost].DI is designed to give great diagnostic errors. The examples below will show you the actual error messages for different scenarios. Check
Concepts
to check it out.
Performance
- [Boost].DI has none run-time overhead and compiles faster than Java's DI frameworks. Check
Benchmarks
to see more.