Opened 9 years ago
Closed 9 years ago
#8603 closed Bugs (invalid)
BOOST_PARAMETER_CONSTRUCTOR with no required arugments
Reported by: | Owned by: | Daniel Wallin | |
---|---|---|---|
Milestone: | Component: | parameter | |
Version: | Boost 1.53.0 | Severity: | Showstopper |
Keywords: | BOOST_PARAMETER_CONSTRUCTOR | Cc: |
Description
The following variation on the example from the boost::parameter tutorial, where the required parameter is changed to optional, fails to compile. myclass_impl is passed an empty agrument list.
#include <iostream> #include <boost/parameter.hpp> BOOST_PARAMETER_NAME(name) BOOST_PARAMETER_NAME(index) struct myclass_impl { template <class ArgumentPack> myclass_impl(ArgumentPack const& args) { std::cout << "name = " << args[_name] << "; index = " << args[_index] << std::endl; } }; struct myclass : myclass_impl { BOOST_PARAMETER_CONSTRUCTOR( myclass, (myclass_impl), tag , (optional (name, *) (index, *) ) ) // no semicolon }; int main(int argc, char * argv[]) { myclass C(_name="hello", _index=0); }
Compilation output:
In instantiation of 'myclass_impl::myclass_impl(const ArgumentPack&) [with ArgumentPack = boost::parameter::aux::empty_arg_list]': ...
Attachments (1)
Change History (3)
by , 9 years ago
comment:1 by , 9 years ago
This bug should be closed. It was pointed out on the devel mailing list that optional arguments to BOOST_PARAMETER_CONSTRUCTOR must be extraced with a '|' default specifier (e.g. arg[_name | ""]).
However, this should still be explicitly stated in the documentation.
comment:2 by , 9 years ago
Milestone: | To Be Determined |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
example reproducing bug