This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Implement N3642 - User-defined Literals for Standard Library Types
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Ed Smith-Rowland <3dw4rd at verizon dot net>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 31 May 2013 18:12:08 +0100
- Subject: Re: Implement N3642 - User-defined Literals for Standard Library Types
- References: <51A8B078 dot 9000308 at verizon dot net>
On 31 May 2013 15:15, Ed Smith-Rowland wrote:
> Greetings,
>
> This patch implements N3642 - User-defined literals for
> std::chrono::duration and std::basic_string
> and N3660 - User-defined literals for std::complex.
Great, thanks!
> User-defined literals were separated into two papers because of some
> controversy about noexcept for complex literals.
> If desired, I could split the patch into two bits for the two proposals.
> OTOH, I'm pretty sure complex literals will make it in.
I'm not so sure, and if they do they might use "if" as the suffix
rather than "i_f", so please split this patch so the non-complex parts
can go in.
I don't think you need to touch config/abi/pre/gnu.ver, al lthe new
functions are inline and not exported from the library, so you don't
need to version symbols that aren't in the library (in fact, you
*can't* version symbols that aren't in the library!)
It looks like the changes to existing headers could be simplified by
not closing and reopening the namespace, i.e. instead of:
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
[...]
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
+#if __cplusplus > 201103L
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+inline namespace literals {
+inline namespace string_literals {
[...]
Just put the new stuff inside the already open namespace, i.e.
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
[...]
+#if __cplusplus > 201103L
+
+inline namespace literals {
+inline namespace string_literals {
[...]
+} }
+#endif
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace