分类: C/C++
2008-12-10 19:25:33
错误原因:
标准模板里面的vector模板的begin()方法和end()方法返回的都是const iterator指针
如果是用的是非const的迭代器指向了const的迭代器,即,使用const iterator 指向了const_iterator,会使得可以使用强转化
代码修改:
(一)COMMON/h/AAA_AA_repo/ServiceFactory.H:
template< class S >
class ServiceFactory
{
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
public:
typedef
std::vector
typedef
std::vector
typedef
std::vector
。。。。。。。。。。。。。。。。。。。。。。。。。。。。
template<class S>
ExternalService* ServiceFactory
::lookupService(String n, String o)const
{
1:
ServiceconstIter begin = array_.begin();
更改前的状态:
// ServiceIter begin = array_.begin();
//Coding Standards checking failed: parse error; Coding Standards checking failed: configuration error
2:
ServiceconstIter end = array_.end();
更改前的状态:
// ServiceIter end = array_.end();
//Coding Standards checking failed: parse error; Coding Standards checking failed: configuration error
(二)**r.cc:
//cpptest
std::vector
// std::vector<AaaAaa*>::iterator it(listAaaAaa_.begin());
std::vector<AaaAaa*>::const_iterator end(listAaaAaa_.end());
// std::vector<AaaAaa*>::iterator end(listAaaAaa_.end());
vector<AaaAaa*>::const_iterator it(listAaaAaa_.begin());
// vector<AaaAaa*>::iterator it(listAaaAaa_.begin());
vector<AaaAaa*>::const_iterator end(listAaaAaa_.end());
// vector<AaaAaa*>::iterator end(listAaaAaa_.end());
(三)****.cc :
//cpptest
vector<AaaAaa*>::const_iterator
it (aaa.getAaaAaaContainer()->getListAaaAaa().begin());
//vector<AaaAaa*>::iterator
it (aaa.getAaaAaaContainer()->getListAaaAaa().begin());
vector<AaaAaa*>::const_iterator end(med.getAaaAaaContainer()->getListAaaAaa().end());
//vector<AaaAaa*>::iterator end(aaa.getAaaAaaContainer()->getListAaaAaa().end());
(四)*****.cc:
// cpptest
// std::vector
// std::vector
std::vector
std::vector