Re: [ Maybe offtopic ] on c++ namespace aliasing
Re: [ Maybe offtopic ] on c++ namespace aliasing
- Subject: Re: [ Maybe offtopic ] on c++ namespace aliasing
- From: Pascal Bourguignon <email@hidden>
- Date: Mon, 02 Jan 2017 18:31:10 +0100
On 2 Jan 2017, at 15:11, Ariel Feinerman < email@hidden> wrote:
I tried to figure out how to write a namespace compatible c++ code between various standard versions, and find out that it is impossible. Are the any Xcode tools or scripts (possibly, clang cpecific) that can do the trick?
I wish use everywhere std::some_class which can expand to boost:: or custom_namespace::some_class if compiler uses older c++ version.
Thank you in advance.
Just #define it!
[pjb@despina :0.0 cpp]$ for f in namespace.cc main.cc ; do printf '=== %s ====================\n' $f ; cat $f ; done // -*- mode:c++ -*-
#include <iostream> #ifndef s #define ss(x) s(x) #define s(x) #x #endif
namespace MYNAMESPACE {
class Greeter{ public: void sayHello(){ std::cout<<"Hello "<<ss(MYNAMESPACE)<<"!"<<std::endl; } };
}
#define MYNAMESPACE foo #undef MYNAMESPACE
#define MYNAMESPACE bar #undef MYNAMESPACE
int main(){ foo::Greeter foo; bar::Greeter bar; foo.sayHello(); bar.sayHello(); return 0; } [pjb@despina :0.0 cpp]$ SRC=""http://main.cc" class="">main.cc" ; EXE="namespace" ; g++ -I. -L. -g3 -ggdb3 -o ${EXE} ${SRC} && ./${EXE} && echo status = $? Hello foo! Hello bar! status = 0 [pjb@despina :0.0 cpp]$
-- __Pascal J. Bourguignon__
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden