Also, ich bin leider kein Freund von const_cast, da ich schon so manche Embedded C++ Compiler gesehen habe, welche const auf ihre ganz eigene Weise interpretiert haben.
Deswegen habe ich mal ein wenig gegrübelt. Du sagst dass die find Funktion nicht trivial ist, also warum nicht eine eigene Template-Find Funktion schreiben`?
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
template <class _InIt, class _Ty>
_InIt MySpecialFind(_InIt _First, const _InIt _Last, const _Ty& _Val)
{
// Fill me
return std::find(_First, _Last, _Val);
}
struct Test
{
std::vector<int> v;
auto find(int val)
{
return MySpecialFind(v.begin(), v.end(), val);
}
auto find(int val) const
{
return MySpecialFind(v.begin(), v.end(), val);
}
};
int main()
{
Test c;
Test const n;
c.find(13);
n.find(13);
//*c.find2(13) = 14;
//*n.find2(13) = 14;
return 0;
}