Compilation error when no required arg in template class
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Use the reproducer in the issue with boost/parameter.hpp as the starting point, and compile it with both clang++ and g++ to confirm the reported diagnostics. Trace the BOOST_PARAMETER_MEMBER_FUNCTION expansion for the template class when the only parameter is optional. Done means the example compiles and both somebody::f() and somebody::f(4) work across the affected compilers.
Written by the indexing model from the issue text.
Description
Hi boost developers.
I have some compilation trouble when I want to use a BOOST_PARAMETER_MEMBER_FUNCTION with no required argument in a template class. There is no issue for non template class or if I add one require arg.
This code can reproduce my issue (tested with several version of boost 1.65,1.69,1.70,1.71,1.72)
#include <iostream>
#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME(arg1)
template <typename T>
struct somebody
{
BOOST_PARAMETER_MEMBER_FUNCTION(
(void), static f, tag, (optional (arg1,(int),0))
)
{
std::cout << arg1 << std::endl;
}
};
#include <boost/core/lightweight_test.hpp>
int main()
{
somebody<double>::f();
somebody<double>::f(4);
return boost::report_errors();
}
The error obtained with clang++ :
error: template argument for template type parameter must be a type; did you forget 'typename'?
The error obtained with g++ :
In file included from /usr/include/boost/parameter.hpp:18,
from test_boostparameter.cpp:2:
test_boostparameter.cpp:9:3: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> template<class Args> struct somebody<T>::boost_param_result_11f'
BOOST_PARAMETER_MEMBER_FUNCTION(
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_boostparameter.cpp:9:3: note: expected a type, got 'boost::parameter::aux::argument_pack<somebody<T>::boost_param_params_11f<int> >::type'
test_boostparameter.cpp:9:3: error: expected ';' at end of member declaration
BOOST_PARAMETER_MEMBER_FUNCTION(
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_boostparameter.cpp: In function 'int main()':
test_boostparameter.cpp:21:23: error: cannot call member function 'int somebody<T>::f() [with T = double]' without object
somebody<double>::f();
- Dominant language
- C++
- Stars
- 16
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/parameter
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
All issues in boostorg/parameter
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
EsotericSoftware/spine-runtimes#3186 ·
-
An empty line splits a signature where an ordinary comment is right above an argument's HaddockOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
mrkkrp/tilia#213 · 1 comment ·
Maintainers usually reply within 1 day
-
Round video messages start gray and blocky with libx264: encoder is configured for 1,000,000 fpsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
telegramdesktop/tdesktop#31422 ·
Maintainers usually reply within 9 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
duckdb/duckdb-quack#299 ·
Maintainers usually reply within 1 day