boostorg / boostorg/proto

Lazy functions make_expr() intended behaviour ?

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
23
Forks
41
PR merge metrics
No merged PRs in 30d

Description

Hi

```cpp
using namespace boost;
template
struct pow_fuc
{
using result_type = double;
result_type operator()()
{
return std::pow(2,Exp);
}
};
template
typename proto::result_of::make_expr ,
const Arg&>::type
pow(const Arg& c)
{
return proto::make_expr(pow_fuc(),boost::ref(c));
}
int main()
{
auto pi = proto::lit(3.17);
pow<3>(pi);
return 0;
}
```

The function call operator of pow_fuc doesn't receive any arguments, but while constructing the expression node for pow function, I'm passing the argument to the function call operator
```cpp
return proto::make_expr(pow_fuc(),boost::ref(c));
```
My compiler doesn't throws any error messages and compiles fine. I don't know exactly whether this is the intended behaviour of proto. If it is a expected behaviour why it is so ?
I'm believing that child expr nodes are captured by reference and used as the argument for pow_fuc call operator. Whether my assumption is wrong ? If wrong, Can you please explain me
Thank you very much :)

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.