473,472 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

restrictions of std namespace

Hello,

I learned that we are not allowed to add any new templates or classes
or functions or anything else to std namespace. Does it mean that
"std" can never be extended? I can't even add any simple function or
class?

Thanks,
Jess

Jun 15 '07 #1
6 1879
Jess wrote:
Hello,

I learned that we are not allowed to add any new templates or classes
or functions or anything else to std namespace.
The rule is less strict. We're allowed to add any specialisations of
templates from 'std' _to_ 'std'.
Does it mean that
"std" can never be extended? I can't even add any simple function or
class?
Nothing simple. Only specialisations of standard templates.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 15 '07 #2
On Jun 15, 10:45 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Jess wrote:
Hello,
I learned that we are not allowed to add any new templates or classes
or functions or anything else to std namespace.

The rule is less strict. We're allowed to add any specialisations of
templates from 'std' _to_ 'std'.
Does it mean that
"std" can never be extended? I can't even add any simple function or
class?

Nothing simple. Only specialisations of standard templates.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

Thanks! Also, does the specialized version have to be in the same
namespace as std? is it legal if i use another namespace or use global
namespace?

Thanks,
Jess

Jun 15 '07 #3
Jess wrote:
On Jun 15, 10:45 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
>Jess wrote:
>>Hello,
>>I learned that we are not allowed to add any new templates or
classes or functions or anything else to std namespace.

The rule is less strict. We're allowed to add any specialisations of
templates from 'std' _to_ 'std'.
>> Does it mean that
"std" can never be extended? I can't even add any simple function or
class?

Nothing simple. Only specialisations of standard templates.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


Thanks! Also, does the specialized version have to be in the same
namespace as std?
Uh... "in the same namespace as std"? By "std" do you just mean "the
standard item it specialises"?
is it legal if i use another namespace or use global
namespace?
Yes, it's legal, as long as your compiler can find it when needed.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 15 '07 #4
I would like to ask two simple questions.

If you extend the std namespace how will you port your code to other
platform?

If you make changes to the std namespace how can others will port
their code to your machine?

Remember it's a **standard** and you are not a member of the standards
committee if you want to extend the std namespace try to become member
of the standards committee. Hope you will become that one day.

Jun 15 '07 #5
Amol wrote:
I would like to ask two simple questions.

If you extend the std namespace how will you port your code to other
platform?
Not sure what problem you are thinking of. Extending 'std' namespace
and portability are orthogonal. Your program will contain the 'std'
namespace extension, and since the contents of 'std' namespace are
essentially the same (the common denominator, anyway) on all platforms,
you just bring your extension to the target platform, and it should
compile without a problem.
If you make changes to the std namespace how can others will port
their code to your machine?
Again, if others have written portable programs, how would an extension
of 'std' namespace in _only one_ of your programs affect that?
Remember it's a **standard** and you are not a member of the standards
committee if you want to extend the std namespace try to become member
of the standards committee. Hope you will become that one day.
WTF are you talking about?

If I need to implement a specialisation of 'std::less' template for
my particular type (for whatever reason), I am _explicitly allowed_ to
do so by the Standard Committee. But the extend of my extension is
limited to my own code. I can share it with you, and then it becomes
part of your own code, and none of that affects anybody else who does
not add those extensions to their programs.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 15 '07 #6
"Jess" <wd***@hotmail.comwrote in message
news:11**********************@z28g2000prd.googlegr oups.com...
Hello,

I learned that we are not allowed to add any new templates or classes
or functions or anything else to std namespace. Does it mean that
"std" can never be extended? I can't even add any simple function or
class?
I think the reasoning behind this is that if you add some new template/class
to namespace std, then a new template/class gets added to the std namespace
in the next version that happens to have a name conflict with yours, your
code breaks. Which is what namespaces are trying to prevent in the first
place, name collisions.

I think the restriction is on adding new names into the std namespace that
may cause collisions. According to V extending templates and such is
allowed, but then you're not adding a *new* name are you?
Jun 16 '07 #7

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

Similar topics

0
by: Tom Dearst | last post by:
Gentlemen/Ladies, Is it common for a host to be so restrictive. http://ftphelp.secureserver.net/linux-phpinfo.html Linux http://ftphelp.secureserver.net/win-phpinfo.html Windows GoDaddy is the...
2
by: Shailendra Batham | last post by:
Hello Gurus, I want to put some restrictions on my attribute tag in my XML Schema, anyone out there have any idea how to do that. here is my XML and the XML Schema <?xml version="1.0"...
3
by: dickster | last post by:
I have a query surrounding about elementFormDefault I have abbreviated the schemas - and hopefully have included all the relevant information I get the following error message...
1
by: Paul van Brouwershaven | last post by:
Hi All, I'm struggling with the WDSL restrictions in PHP/SOAP for a while know. I would like to create some simple restrictions in my WDSL file. The script are running both on the same server...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.