C++ standard documentation [duplicate] - c++

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Where do I find the current C or C++ standard documents?
After reading several websites and books, I notice there is a constant reference to a C++ standard. While reading posts on stackoverflow and c++ forums, the communities encourage following this standard. This encouraged me to Google c++ standard to find out in more detail about the language. Is the standard a book? a published document? a mystic spirit that speaks through some seemingly crazed medium? Is there a single source and a final version that people refer to for verification? Several sites and books claim to be based off the standard, but this is not the same as the standard.
So far, I have found recommendations to look at the ISO standard (which seems to be mostly incomplete drafts) and the GNU c++ documentation at http://gcc.gnu.org/onlinedocs/libstdc++/. I have briefly used these to try to answer some of the questions that come to mind, but I want to make sure these are the proper references to use when answering questions (my own or others) and that I do so according to the proper standard and not something based on the standard (there is a difference).
Just to note:
For me, 99% of all my programming will be done in a Linux environment so there may (or may not be) a different standard for different operating systems

There is a single version of standard. There is no difference between systems( it is one standard). You have to pay go get full version of the standard ( even for PDF file). Everyone is using:
https://github.com/cplusplus/draft [EDITED TO THE NEWEST VERSION]
for free, because it is draft version and it is free. There are some different between draft and released one.

If you want to get a copy of the standard, you can buy it for a small fee from ISO, which is how they fund themselves.
However, if you simply follow the last draft of C++11, which is currently the latest C++ standard, and will remain to be for some time, you will never notice a difference against the released standard.
It is a similar story with POSIX, a standard used for UNIX-like APIs on that family of operating systems. In that case you would want to go here.
However, while a perfect understanding of C++ is highly desirable whatever you do, it may well be that your portability needs will make POSIX somewhat irrelevant to you; either you might only need Linux compatibility, or you might restrict yourself to APIs (such as the standard C++ library or other portable libraries) that will support you even on non-POSIX operating systems.

Related

c++ proposal for new mathematical special functions [duplicate]

When the C++ committee publish a new feature that will be part of the standard library in the next standard of the language, do they also release some source code or some kind of guidance on how to implement that feature?
Let's take unique_ptr as an example. The language committee just defines an interface for that class template and let the compiler vendor implement it as it wants? How exactly does this process of implementation of the standard library features occur?
Can anyone implement parts of the standard library for a platform that doesn't have support for them yet? Let say I would like to implement some cool features of the C++ standard library to use it on a microcontroller environment. How could I do that? Where should I look for information? If I decide to open source my project, can I do that? Will I need to follow exactly what the standard says, or I can write a non-compliant version?
Usually,
every new library feature goes through a proposal.
If the proposal makes it to the C++ committee's Library Evolution Working Group, it goes through a series of iterations (a "tough ground" as I am aware).
It undergoes a series of refinement process as described here
Should it require a (TS) Technical Specification (since C++11), it goes there to be baked. Take for example, the #include <filesystem> was in a Filesystem TS prior to C++17.
One thing I believe the committee likes, is an implementation experience.
More information can be found on the ISOCpp site
Well, as to the implementation:
There are quite a number of "library features" that cannot be implemented purely as a library. they require compiler support. And in these case, compilers provides "intrinsic" that you could hook on to. Take for example, clang provides intrinsics for certain type_traits
Most library features have some implementation experience, mostly from the Boost libraries.
You could actually look into the source code for the default standard library that ships with your compiler:
libc++ for Clang
libstdc++ for GCC
Sadly most of the implementations use a whole bunch of underscores. Mostly because they are reserved for use by the "Standard Library".
Can anyone implement parts of the standard library for a platform that doesn't have support for it yet?
Yes, you can, so far your compiler supports that platform, and the platform or Operating System provides usable API. For example. std::cout, elements of std::ifstream, and so much more requires platform specific support.
Let say I would like to implement some cool features of the C++ standard library to use it on a microcontroller environment. How could I do that?
You can look into the code of others and start from there. We learn from giants. Some Open Source Examples:
ETL
StandardCPlusPlus
uClib++
How could I do that? Where should I look for information?
You could check the paper that introduced the feature into the C++ library. For example, std::optional has a stand-alone implementation here which was used as a reference implementation during the proposal stages.
You could check the standard library, and do a laborious study. :-)
Search the internet. :-)
Or write it from scratch as specified by the standard
Will I need to follow exactly what the standard say or I can write a non-compliant version?
There's is no compulsion to follow what the C++ standard library specifies. That would be your "own" library.
Formally, no. As with all standards out there, C++ Standard sets the rules, and does not gives implementation. However, from the practical standpoint, it is nearly impossible to introduce a new feature into Standard Library without proposed implementation, so you often can find those attached to proposals.
As for your questions on "can you write non-compliant version", you can do whatever you want. Adoption might depend on your compliance, or might not - a super-widely adopted MSVC is known to violate C++ standard.
Typically, a new feature is not standardized, unless the committee has some solid evidence that it can be implemented, and will be useful. This very often consists of a prototype implementation in boost, a GNU library, or one of the commercial compiler vendors.
The standard itself does not contain any implementation guidance - it is purely a specification. The compiler vendors (or their subcontractors) choose how to implement that specification.
In the specific case of unique_ptr, it was adopted into the standard from boost::unique_ptr - and you can still use the latter. If you have a compiler that will compile for your microcontroller, it is almost certain that it will be able to build enough of boost to make unique_ptr work.
There is nothing stopping you from writing a non-conforming implementation (apart from the trivial point that if you sold it as being standards-conforming, and it wasn't you might get your local equivalent of Trading Standards come knocking.)
The committee does not release any reference implementations. In the early days, things got standardized and then the tool developers went away and implemented the standard. This has changed, and now the committee looks for features that have been implemented and tested before standardization.
Also major developments usually don't go directly into the standard. First they become experimental features called a Technical Specification or TS. These TS may then be incorporated into the main standard at a later date.
You are free to write you own implementation of the C++ standard library. Plum Hall has a test suite (commercial, I have no connection, but Plum Hall are very involved with C++ standardization).
I don't see any issue with not being conformant. Almost all implementations have some extensions. Just don't make any false claims, especially if you want to sell your product.
If you're interested in getting involved, this can be done via your 'National Body' (ANSI for the USA, BSI for the UK etc.). The isocpp web site has a section on standardization which would be a good starting place.

OCaml standard committee?

I am doing a presentation on OCaml, I want to put if there is a standard comittee or not. I searched the internet far and wide and I couldn't get an answer for that, so I am asking for help here.
OCaml does not follow any national or international standard. The language is whatever the Gallium (formerly Cristal) group at INRIA want it to be.
The OCaml language does not have any standard, as there is only one implementation of it, namely OCaml itself. Some other experimental versions of OCaml exist (OCaml Java, one version that used to run on .NET) but as far as I know, none of them is considered serious enough (as of now) to be an alternative implementation. The Standard ML language has been standardized (as the name implies!), and implementations of it exist (SML/NJ, AliceML, MoscowML), but OCaml is not SML.
However, several industrial users of OCaml need agreement on the future directions of the language. A structure exists for that purpose, which is called the Caml Consortium http://caml.inria.fr/consortium/; future improvements on the language itself and its implementation may be discussed there. Technical discussions take place on a private list called caml-devel.
If you're talking about an official standard like those produced by ISO, there's no indication of one. Computer languages are handled within ISO (and, to be honest, that's the most important standards body; all national bodies like ANSI and AS) tend to just feed into ISO) with technical committee 1, working group 22 (JTC1/SWG22).
A list of the standards issued for JTC1/SWG22 can be found here and there's not a peep about OCaml.
Although there are some interesting snippets in there, such as Fortran being worked on as late as 2010, and Ruby in there but no Python.
That's not to say there may not be some standardisation effort outside of ISO or the national bodies, but it may be seen as less serious.

Looking for C/C++ language and standard libraries specifications [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Where do I find the current C or C++ standard documents?
I have several C books, and one of them, C by Discovery, explains the language very well. But so far I don't seem to have been able to find the full C/C++ language and library standards and lists of functions, types, etc., in whole detail.
Where is exactly a full standard for C99 and also the older, supposedly more commonly used and accepted, C language standards, the C++ language standards, and their libraries?
Is there some of them I must pay for, or should I just follow what Wikipedia and documentation like that of GCC cite?
Where else should I go to download or get them fully?
The Wikipedia article C99 has a link at the bottom to a draft of the C99 language specification. It is a draft because the final published version you have to pay for. But the draft is basically accurate, so it's a good reference. This is an extremely long specification of the entire language including the library, but possibly not what you are after. To just see the standard library, simply consult the man pages. Consult the Wikipedia article C standard library for a list and summary of the various functions.
For C++, the same deal. The Wikipedia article C++ has links to various drafts of the complete specification, notably the most recent draft of C++ from 2010 (the old C++, before C++0x comes into effect). The Wikipedia article C++0x has similar links to drafts of the soon-to-be-named C++ 2011 standard. But if you are just looking for a reference on the standard library, you can't go past cplusplus.com's reference section, which includes full documentation for the C library (in C++ mode), the IO library, and the STL (containers and other misc utilities). That's what I use as a day-to-day library reference.
The best online copy of C99 I've found is here:
http://busybox.net/~landley/c99-draft.html
If you want the actual standard, I don't think you can just download it. I believe you have to buy a copy from the American National Standards Institute. The GCC documents don't provide all the detail you need for the base language that GCC extended.

Microsoft C++ Language Reference

Whenever any question is asked, and a reference text is needed, I never see MSDN C++ Language Reference being referred.
I was browsing through it and I personally feel that it is extremely well written.
Is there some specific reason it is not used as often as a standard?
Is it because it contains some VC++ specific features?
I believe it's because those of us referencing a reference reference the actual standard itself.
The answer is fairly simple: The MSDN reference is not authoritative. It tells you how Microsoft's compiler behaves, and yes, it usually happens to coincide with what the standard says. But when someone asks how the C++ language deals with some situation, only one text has any authority: the ISO standard.
So when answering questions about C++, people tend to reference the standard.
If you ask specifically about how MSVC implements it, then MSDN would be a perfectly valid source. But most questions are simply about C++.
Or to put it another way: if MSDN contains a typo, then MSDN is wrong. If the ISO standard contains a typo, then that's how the language is defined.
MS has been pretty good about making clear which parts of the document are MS specific or not, so I agree that the MS references are pretty good (particularly if you're interested in MS extensions).
I generally refer to the standards docs if I'm looking for information about "what's standard" because:
I have them (see Where do I find the current C or C++ standard documents? for links to how to get yours)
they're PDFs which I find easier to search and read than the web-based or Windows Help-based MSDN docs
they're definitive (as far as answering questions about the standard)
The biggest drawback is that I don't have an electronic version of the C90 standard, yet..
Is it because it contains some VC++ specific features?
I think that's the basic reason. For example, it often contains info on C++/CLI, not just C++.
VC++ 2010 reference, I think, is careful in distinguishing which part is in the C++ proper and which part is in the C++/CLI. But to refer to the standard, of course it's better to refer to the standard itself. VC++ documentation refers to the standard quite often, too.
One interesting example: just look at all those __XXX keywords!! (The C++ standard has none)
The C++ Standard defines how the C++ language works, the Microsoft C++ Language Reference defines how Microsoft's implementation of that language works.
So if you want to know what behavior is guaranteed independent of the compiler, The Standard is your guide. Some details and certain corner cases are left to be implementation-defined there and every implementation can define extensions to the language, so if you want to use those MSCV specific properties Microsoft's Language Reference should explain them.
Most SO questions on C++ on don't explicitly ask for a MSVC specific answer that might not be true for other compilers. So referring to The Standard gives an general, compiler independent answer, while the MS Language Reference wouldn't hold much weight for anything else than MSVC.

Where can I look at the C++ standard [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Where do I find the current C or C++ standard documents?
I want to use STL with the current program I'm working on and the vendor doesn't support what I feel is a reasonable STL, working is not my idea of reasonable. I have been unable to find a C++ Standard or an STL standard that is not just an API that leaves me wondering if my interpretation is correct or if the vendor interpretation is correct. I've already spent a great deal of time at SGI's site. Any reccomendations? Also, is there any document that's not an API that would be considered the standard?
The draft of the current C++0x standard is available from this page and the official homepage of the C++ standards committee is here.
Information on where to get the current standard document:
Where do I find the current C or C++ standard documents?
Other responses in that question have information on downloads of various drafts of the standards which can be obtained free (the actual ratified standards cannot be obtained free).
The Standard is available as a PDF for ANSI.org. ($18 last time I checked, downloadable).
$18 for a downloadable PDF was considered a breakthrough, since previously ANSI only sold it standards in hardcopy form, for several thousand dollars a copy. (Normally, ANSI standards have a very limit market -- only motorcycle helmet manufacturers are going to buy the ANSI Standard for motorcycle helmets etc), and Standard sales was the primary way ANSI financed it's operation.
Each national standards body in ISO can make the Standard available as they see fit. I'm told British Standards had made a deal to publish it in book form, but I don't know it taht ever came about.
i googled "C++ ansi standard" and clicked the first result
What's available for free on the
Internet?
The C++ standard went through two
Committee Drafts (CDs) which were made
available for public inspection and
comment. Changes made to the second CD
after the public comment period were
submitted to the member bodies for a
vote and became the official standard.
CD2 of the C++ standard is very
similar, but not exactly the same, as
the final standard.
body of a draft (see directory listing for TOC etc)
The book's ISBN is 978-0470846742, if you're interested in treeware. It's quite up to date (includes the Technical Corrigendum). You are right in suspecting it's the definitive resource when arguing with compiler vendors. The standard doesn't prescribe performance, but it does put upper bounds on the big-O complexity of many algorithms