Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Dynamic Variable

Overview
Tutorial
Shapeshifter
Algorithms
User Guide
Types
Functions
Algorithms
Converters
Concepts
Design Rationale
Acknowledgement
Dynamic Reference
Header <boost/libs/trial.protocol/include/trial/dynamic/algorithm/visit.hpp>
Header <boost/libs/trial.protocol/include/trial/dynamic/error.hpp>
Header <boost/libs/trial.protocol/include/trial/dynamic/functional.hpp>
Header <boost/libs/trial.protocol/include/trial/dynamic/token.hpp>
Header <boost/libs/trial.protocol/include/trial/dynamic/variable.hpp>
[Important] Important

Trial.Dynamic is not an official Boost library.

Trial.Dynamic is still work-in-progress.

Trial.Dynamic is a C++11 header-only library with a C++ dynamic variable.

  • The dynamic variable is a tagged union whose type and value can change dynamically during program execution.
  • The dynamic variable supports fundamental data types[8][9] and strings.
  • The dynamic variable supports sequenced and associative containers of dynamic variables and can therefore act as a heterogenous tree data structure.
  • The dynamic variable meets the requirements of Container and therefore works with standard C++ algorithms.
  • The dynamic variable can be customized with an allocator.

The resemblance between dynamic::variable and std::variant is obvious, but there are notable differences. While std::variant supports custom types, dynamic::variable is restricted to the above-mentioned data types and containers. This restriction enables dynamic::variable to adhere to the Container concept, and thus to have a richer interface that works with algorithms.

Dynamic variables are useful for carrying configuration data, constructing parse trees for data formats, and protocol serialization.



[8] Characters (char, wchar_t, char16_t, and char32_t) are not supported directly, but only indirectly via strings.

[9] void is not a regular type, so it has been replaced with the dynamic::nullable type and the dynamic::null value.


PrevUpHomeNext