- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have "expression must be a modifiable lvalue" error in compile time. I've tried to compile both icpc and g++ but nothing changed. I'm trying to learn TBB and try to write findMinFloat "finding mininmum element of float array" with parallel_reduce. My code block is at the below. I have the error while overloading operator() but I do not have while writing a regular function such as foo(). What can be my problem ?
class findMinFloat
{
public:
float *farr;
int size;
float minValue;
int minIndex;
void operator()(const blocked_range<int> & range) const
{
for(int i = range.begin(); i < range.end(); i++)
{
if(farr<minValue)
{
// cout<<farr<<endl;
minValue = farr; // error #137: expression must be a modifiable lvalue
minIndex = i;/**/ // error #137: expression must be a modifiable lvalue
}
}
}
void foo()
{
for(int i =0; i < 100; i++)
{
if(farr<minValue)
{
minValue = farr; //NO ERROR
minIndex = i;/**/ //NO ERROR
}
}
}
/* findMinFloat(float *fp)
{
farr = fp;
size = 100;
minValue = 500;
minIndex = -1;
}
/* findMinFloat(findMinFloat &x, split):
farr(x.farr), minValue(500), minIndex(-1),size(100)
{};/**/
};/**/
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The operator()() of the body class for parallel_reduce should not be const.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alexey Kukanov (Intel) wrote:
The operator()() of the body class for parallel_reduce should not be const.
Thanks for your answer. It solves my problem.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page