On 9/04/2018 7:55 PM, Charles Mills wrote:
David -

Thanks for everything. I guess I will PMR it. As pointed out in another thread, 
the PMR process is painful. It does me little good because I can't ship a 
product that requires some obscure PTF -- the sales team would kill me.

I feel your pain.


Nah, the tr1 doesn't bother me. It's like having to code those pesky semicolons 
or those pesky double equal signs. It is what it is. My Visual Studio accepts 
but does not require the tr1:: for regex. I use Visual Assist and it tends to 
autocomplete these things for me anyway, so it is little trouble.

I used namespace when I started out in C++ but then decided I was collapsing 
the name space. I would rather have to code std:: every time than to have some 
weird problem caused by an unexpected symbol name duplication.

Me too. I avoid usings like "using namespace std". The using I posted brings the tr1 namespace into std so I can use std::regex and not std::tr1::regex. I don't use visual studio and clang and g++ require including special headers like <tr1/regex> which I would rather not do.

I use auto sometimes but tend not to think to use it except in template 
functions and that sort of thing.

auto has moved on significantly since C++14 and C++17 and you can now define a function with an auto return value. It's also important for lambda's. Especially useful for iterators so you don't have to code something like std::unsorted_map<int, std::string>::iterator or use typedefs.


Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of David Crayford
Sent: Monday, April 9, 2018 12:38 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

Charles,

Do you get fed up with having to specify the pesky tr1 namespace? It makes it 
difficult to share code between z/OS and distributed. You can work around that 
with a useful namespace declaration.
Also, if you are using LANGLVL(EXTENDED0X) you can significantly cut down on 
the verbosity of variable definitions by using auto type inference.

#include <cstdio> // bring C stdio runtime into the std namespace

#define __IBMCPP_TR1__ 1
#include <regex>

namespace std { using namespace tr1; }  // be gone pesky tr1 namespace

struct myRegex
{
      std::regex regexObject;
};

int main(int argc, char* argv[])
{
      printf("RegEx test 4/6/2018\n");
      auto flags = std::regex::extended;     // necessary for error
      auto *myRegex_p = new myRegex;
      myRegex_p->regexObject.assign("foo", flags);
      delete myRegex_p;
      return 0;
}

On 9/04/2018 2:09 AM, Charles Mills wrote:
Believe it or not, it appears to be a bug in the C++ runtime. Anyone
who wants to prove me wrong is welcome to try the below. I have tested
only on z/OS V2R2.

#include <stdio.h>

#define __IBMCPP_TR1__ 1
#include <regex>

class myRegex
{
public:
      std::tr1::regex regexObject;
};

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to