STL VS13 C++: Error C4996 not disabling -


i have code in vs13:

double distance(vector <double> point) {     return sqrt(inner_product(point[0], point[4], point, 0)); }  int main() {     vector < double > point {2, 2, 2, 2};     cout << distance(point);     cin.get(); } 

which invokes

    error c4996 ('std::_inner_product2': function call parameters may unsafe - call relies on caller check passed values correct. disable warning, use -d_scl_secure_no_warnings)  c:\program files\microsoft visual studio 12.0\vc\include\xutility(372): error c2825: '_iter': must class or namespace when followed '::'     c:\program files\microsoft visual studio 12.0\vc\include\xutility(372): error c2039: 'value_type' : not member of '`global namespace''     c:\program files\microsoft visual studio 12.0\vc\include\xutility(372): error c2146: syntax error : missing ';' before identifier 'value_type'     c:\program files\microsoft visual studio 12.0\vc\include\xutility(372): error c2602: 'std::iterator_traits<_init>::value_type' not member of base class of 'std::iterator_traits<_init>' 

i know there many similar questions here. read documentation on msdn.

as result, tried next solutions:

1) #define _scl_secure_no_warnings

from past reviews seemed work me causes whole bunch of errors like:

c:\program files\microsoft visual studio 12.0\vc\include\xutility(371): error c2825: '_iter': must class or namespace when followed '::' 

2)

#pragma warning(disable:4996) #pragma warning(default:4996) 

caused same errors;

3) project properties -> configuration properties -> c/c++ -> general -> sdl checks -> no.

just not work.

could take , write how can disable error? thanks!

i think mean following function

double distance( const std::vector<double> &point )  {     return std::sqrt( std::inner_product( point.begin(), point.end(), point.begin(), 0.0 ) ); } 

here demonstrative program

#include <iostream> #include <vector> #include <numeric> #include <cmath>  double distance( const std::vector<double> &point )  {     return std::sqrt( std::inner_product( point.begin(), point.end(), point.begin(), 0.0 ) ); }  int main() {      std::vector<double> point = { 2, 2, 2, 2 };      std::cout << distance( point ) << std::endl; } 

the output is

4 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -