I am using c++ for my project and facing this error in one of my functions.
"a const_cast can only adjust type qualifiers; it cannot change the underlying type"
I am working with thrust library and all my vectors are device type. The problem is that when I change host_vector to device_vector, I get errors and the above error is one of them. I need to cast the iterator of find_if(inode) to Node*(Node is a struct). As I mentioned, this problem appears after changing the host_vector to the device_vector. Before that everything's fine. Unfortunately, I cannot find any solution to this problem so I'm stuck a bit:| I'm not even sure if I can cast this iterator to the desired struct type. By the way, if it helps, the type of inode after changing to device_vector is sth like this: thrust::detail::normal_iteratorthrust::device_ptr<Node>
Could someone help me, please...
Here is my function: I have tried (*inode), (&inode), (&(*inode)), and so on. And none of them worked.
Node* getItem(int const& p_itemValue)
{
auto inode = thrust::find_if(thrust::device, _itemList.begin(), _itemList.end(), __host__ __device__ [&p_itemValue](Node const& p_node)
{
return p_node._itemValue == p_itemValue;
});
//int index = inode - _itemList.begin();
if (inode != _itemList.end())
{
Node* node = const_cast<Node*>(inode);
return node;
}
return nullptr;
}