Re: [boost] [multi-array] compiler errors with visual studio 2012 (nfarnsworth@web.de)
Date: Sat, 23 Mar 2013 14:12:24 +0100 (CET) From: nfarnsworth@web.de To: boost@lists.boost.org Subject: [boost] [multi-array] compiler errors with visual studio 2012 Message-ID:
Content-Type: text/plain; charset="UTF-8" Hello, have this c++ example which compiles with Visual Studio 2010 but with Visual Studio 2012 I got this compiler errors: 1>------ Build started: Project: MultiArrayDemo, Configuration: Debug Win32 ------ 1> MultiArrayDemo.cpp 1>d:\sandbox\multiarraydemo\multiarraydemo\multiarraydemo.cpp(11):error C2059: syntax error : '<' 1> d:\sandbox\multiarraydemo\multiarraydemo\multiarraydemo.cpp(25) : see reference to class template instantiation 'Data<T>' being compiled 1>d:\sandbox\multiarraydemo\multiarraydemo\multiarraydemo.cpp(11):error C2238: unexpected token(s) preceding ';' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== The example uses the boost 1.53 version. Here is the example code: #include "stdafx.h" #include
const int rows = 3; const int cols = 5; template<class T> struct Data { typedef boost::multi_array data_type; typedef typename data_type::array_view<1>::type view_type; //here is the first error typedef typename data_type::index_range range; Data() :A(boost::extents[rows][cols]) { double tmp[] = {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0}; A.assign(tmp,tmp+ (rows * cols)); } data_type A; }; int _tmain(int argc, _TCHAR* argv[]) { Data<double>* data = new Data<double>(); Data<double>::view_type myView = data->A[boost::indices[0][Data<double>::range()]]; delete data; return 0; } Does anybody know how to solve this problem? Best regards and thank you in advance Niklas
According to Microsoft, the code is non-conformant. Visual Studio 2010 allowed the code to be compiled, but 2012 tightened the requirement. See: http://msdn.microsoft.com/en-us/library/bb531344.aspx (Second point, "Use the template keyword...", but note that they highlighted the wrong keyword). The simple fix is to add the keyword 'template': typedef typename data_type::template array_view<1>::type view_type; //here is the first error Dan Searles
participants (1)
-
Dan Searles