473,410 Members | 1,907 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,410 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 5635
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: 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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.