有一个C++模板,ansiC++的,请帮忙看看VC++怎么编译
是一个GsTL(http://gstl.sourceforge.net/)的模板,用于科学计算,readme里面说支持ansiC++的都能编译,不过我用vc2008却不行,说是:
错误4error C3083: “value_type”:“::”左侧的符号必须是一种类型
弄不清怎么回事,请高手帮帮忙。
[code=C]
/* GsTL: the Geostatistics Template Library
*
* Author: Nicolas Remy
* Copyright (c) 2000 The Board of Trustees of the Leland Stanford Junior University
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1.Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2.Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
* 3.The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __GSTL_LINEAR_COMBINATION_H__
#define __GSTL_LINEAR_COMBINATION_H__
#ifdef __GNUC__
#pragma interface
#endif
#include <GsTL/utils/gstl_error_messages.h>
/** This function computes the linear combination between the
* scalars in range [begin_weights; end_weights) and the elements
* of the neighborhood that neighbors points to.
*/
template
<
class InputIterator,
class Neighborhood
>
double
linear_combination(InputIterator begin_weights, InputIterator end_weights,
const Neighborhood& neighbors)
{
//double result=0.0;
[color=#FF0000] typename Neighborhood::value_type::property_type result(0);
[/color]
typename Neighborhood::const_iterator it= neighbors.begin();
typename Neighborhood::const_iterator end = neighbors.end();
for( ; it != end ; ++it ) {
gstl_assert(begin_weights != end_weights);
result += it->property_value() * (*begin_weights);
begin_weights++;
}
return result;
}
#endif
[/code]
[解决办法]
Neighborhood应该是一个class,但没有找到它的定义,因此编译器不认识了
把Neighborhood声明的头文件包含进来
[解决办法]
看看Neighborhood是在哪声明的
[解决办法]
Neighborhood是模板参数啊,传进去的实际类是什么?
[解决办法]
额 neighborhood里面没有一个value_type的定义。