× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I am attempting to compile the following code under the newer compiler
under V7R3 and the LANGLVL *EXTENDED0X option enabled. I am using the
5799PTL 'icc' compiler front-end to do this. The command default for
CRTCPPMOD has been altered to always have *EXTENDED0X on by default. I am
getting this:

"testme.cpp", line 14.18: CZP0130 (30) "start" is not declared.

The offending line looks like:

T::size_type start = 0;

So, is there a change to the C++11 syntax here? Thanks in advance, as
always. Here is the test program.

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <unistd.h>

using namespace std;


template<typename T> vector<T> split(const T & str, const T & delimiters)
{
vector<T> v;
T::size_type start = 0;
size_t pos = str.find_first_of(delimiters, start);
while (pos != T::npos) {
if (pos != start) { // ignore empty tokens
v.push_back(str.substr(start, pos - start));
}
start = pos + 1;
pos = str.find_first_of(delimiters, start);
}
if (start < str.length()) { // ignore trailing delimiter
v.push_back(str.substr(start, pos - start));
}
return v;
}


int main(int argc, char* argv[])
{
string str = "this,is,a,test, of whatever, like, ok.";
vector<string> v = split<string>(str, ", ");
for (int i = 0; i < v.size(); ++i) {
cout << v[i] << endl;
}
}



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.