C++ boost::parameter














































C++ boost::parameter




#include <boost/parameter.hpp>
#include <string>
#include <iostream>
#include <ios>

BOOST_PARAMETER_NAME(a)
BOOST_PARAMETER_NAME(b)
BOOST_PARAMETER_NAME(c)
BOOST_PARAMETER_NAME(d)
BOOST_PARAMETER_NAME(e)

BOOST_PARAMETER_FUNCTION(
(
void),
complicated,
tag,
(required
(a, (
int))
(b, (
char))
(c, (
double))
(d, (
std::string))
(e, *)
)
)
{

std::cout << a << '\n';
std::cout << b << '\n';
std::cout << c << '\n';
std::cout << d << '\n';
std::cout << e << '\n';
}

int main()
{
complicated(_c =
3.14, _a = 1, _d = "Boost", _b = 'B', _e = true);
}


Explanation:a function complicated(), which expects five parameters. The parameters may be passed in any order. Boost.Parameter provides the macro  to define such a function.


Comments