concept checking isn't really for the programmers writing the STL, it's for the users.Quote:
Originally Posted by anonytmouse
for example, ever done this?
the problem with this code is that MyClass has no available operator=, but the error output (VC7.1) produced isCode:
#include <vector>
class MyClass
{
public:
MyClass(int x)
:m_x(x)
{}
private:
const int& m_x;
};
int main()
{
std::vector<MyClass> x;
x.push_back(MyClass(2));
}
and clicking on it brings you to this function:Code:c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xutility(1136) : error C2582: 'operator =' function is unavailable in 'MyClass'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\vector(862) : see reference to function template instantiation 'void std::fill<std::vector<_Ty>::_Tptr,_Ty>(_FwdIt,_FwdIt,const _Ty &)' being compiled
with
[
_Ty=MyClass,
_FwdIt=std::vector<MyClass>::_Tptr
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\vector(809) : while compiling class-template member function 'void std::vector<_Ty>::_Insert_n(std::vector<_Ty>::iterator,std::vector<_Ty>::size_type,const _Ty &)'
with
[
_Ty=MyClass
]
f:\tests\dlltest\testDll\testDll.cpp(19) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
with
[
_Ty=MyClass
]
the average C++ beginner sees this, screams and thinks "OMG my STL has been hax0red!!"Code:// TEMPLATE FUNCTION fill
template<class _FwdIt,
class _Ty> inline
void fill(_FwdIt _First, _FwdIt _Last, const _Ty& _Val)
{ // copy _Val through [_First, _Last)
for (; _First != _Last; ++_First)
*_First = _Val;
}
A concept checked stl would produce something more along the lines of
and point you at the MyClass definitionQuote:
MyClass does not implement the Assignable concept