boostorg / boostorg/parameter

Compilation error when no required arg in template class

Open
#102 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16
Forks
42
PR merge metrics
No merged PRs in 30d

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
#include

BOOST_PARAMETER_NAME(arg1)

template
struct somebody
{
BOOST_PARAMETER_MEMBER_FUNCTION(
(void), static f, tag, (optional (arg1,(int),0))
)
{
std::cout << arg1 << std::endl;
}
};

#include

int main()
{
somebody::f();
somebody::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 template struct somebody::boost_param_result_11f'
BOOST_PARAMETER_MEMBER_FUNCTION(
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_boostparameter.cpp:9:3: note: expected a type, got 'boost::parameter::aux::argument_pack::boost_param_params_11f >::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::f() [with T = double]' without object
somebody::f();
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.