473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C++ programmers! How do you use unnamed 'namespace's ?

Dear mates,
This is a small survey for C++ programmers to speak their mind about
the uses and/or potential advantages and disadvantages resulting from
the use of the aforementioned C++ feature in ralistic code in various
programming domains.
Thank you.

//rk
Jul 19 '05 #1
3 5633
Hi Razmig,

"Razmig K" <st*********@postmaster.co.uk> wrote in message
news:3c**************************@posting.google.c om...
| This is a small survey for C++ programmers to speak their mind about
| the uses and/or potential advantages and disadvantages resulting from
| the use of the aforementioned C++ feature in ralistic code in various
| programming domains.

I *always* use an anonymous namespace around small utility classes
(e.g. predicates and functors for STL algorithm calls) defined in
an implementation (.cpp) file. This is the easiest and the only safe
way to avoid name clashes in C++.

For isolated internal functions and global variables (if ever...),
I may still use 'static' instead of an anonymous namespace.
In spite of it being deprecated -- old habits die hard...
(and using 'static' helps portability to older & C compilers).

Realistic code: absolutely
Programming domain: from embedded/RT SW to Mloc OO/GUI applications.
Cheers,
Ivan

--
http://www.post1.com/~ivec <> Ivan Vecerina
Jul 19 '05 #2

"Razmig K" <st*********@postmaster.co.uk> wrote in message
news:3c**************************@posting.google.c om...
Dear mates,
This is a small survey for C++ programmers to speak their mind about
the uses and/or potential advantages and disadvantages resulting from
the use of the aforementioned C++ feature in ralistic code in various
programming domains.


They are useful either in large programs or when using third party libraries
(where you're using someone else's code, but can't change it) to avoid name
clashes.
Jul 19 '05 #3
Razmig K wrote:
This is a small survey for C++ programmers to speak their mind about
the uses and/or potential advantages and disadvantages resulting from
the use of the aforementioned C++ feature in ralistic code in various
programming domains.


I use it when I want to introduce filescope. For instance, I'm using an
algorithm like for_each(), and I want to have functor to pass to it, then I
put the functor in the anonymous namespace in the .cpp file. Kinda a
replacement for static.

--
John L. Fjellstad

A: Top posting!
Q: What is the most irritating thing on Usenet?
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Damian Brown | last post by:
www.phpexpert.org
175
by: Lucas Raab | last post by:
One thing I've always kind of wondered is what is the average age of a Python programmer?? What age groups use Python?? Something to think about....
108
by: Zooko O'Whielacronx | last post by:
I'm a fan of Greg Ewing's PyGUI . I used it to code a simple game for my son , and enjoyed it. Programming with wxPython feels like programming with a C++ tool that has been wrapped in Python....
242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
176
by: basecamp | last post by:
just checking the average age of programmers using this group -- thanks
55
by: amanda992004 | last post by:
Excluding the factors of the brain capability, i.e I am not asking about this factor, if you are a single, aside from enjoying coding or debugging, how do you make time to eat properly, i.e...
7
by: guy | last post by:
Stirring up trouble here;) why is it that C# programmers try and denigrate VB.NET while VB.NET developers seem to have no problem with C# but just prefer VB.NET? I use both and this generally seems...
8
by: M_Mann | last post by:
Hello, Pls excuse if you consider this off-topic. Conceptual artists seek programmers here. We are authors of "Exhibition of Living Managers" (MANAGEX, www.managex.info) which is is global...
6
by: Biel | last post by:
Folks, One curiosity; - When can I affirm that one programmer C++ have the advanced level? - Is there some classical definition of parameters applied to C++ for define it?
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.