[cfe-commits] [libcxx] r153968 - in /libcxx/trunk: include/utility src/utility.cpp

Richard Smith richard at metafoo.co.uk
Tue Apr 3 15:06:01 PDT 2012


Is there a reason to want external linkage for this symbol in C++98 mode?
If not, it seems you could use:

_LIBCPP_CONSTEXPR const piecewise_construct_t piecewise_construct = {};

(and delete utility.cpp). This initialization should not require a dynamic
initializer in C++98 mode, and the internal-linkage 'piecewise_construct'
object should be optimized out of existence at -O1.

On Tue, Apr 3, 2012 at 2:54 PM, Howard Hinnant <hhinnant at apple.com> wrote:

> On Apr 3, 2012, at 5:52 PM, Eli Friedman wrote:
>
> > On Tue, Apr 3, 2012 at 2:09 PM, Howard Hinnant <hhinnant at apple.com>
> wrote:
> >> Author: hhinnant
> >> Date: Tue Apr  3 16:09:48 2012
> >> New Revision: 153968
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=153968&view=rev
> >> Log:
> >> constexpr support for <utility>.  Patch contributed by Jonathan Sauer.
> >>
> >> Modified:
> >>    libcxx/trunk/include/utility
> >>    libcxx/trunk/src/utility.cpp
> >>
> >> Modified: libcxx/trunk/include/utility
> >> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=153968&r1=153967&r2=153968&view=diff
> >>
> ==============================================================================
> >> --- libcxx/trunk/include/utility (original)
> >> +++ libcxx/trunk/include/utility Tue Apr  3 16:09:48 2012
> >> @@ -206,8 +206,11 @@
> >>  }
> >>
> >>  struct _LIBCPP_VISIBLE piecewise_construct_t { };
> >> -//constexpr
> >> +#ifdef _LIBCPP_HAS_NO_CONSTEXPR
> >>  extern const piecewise_construct_t piecewise_construct;// =
> piecewise_construct_t();
> >> +#else
> >> +constexpr piecewise_construct_t piecewise_construct =
> piecewise_construct_t();
> >> +#endif
> >>
> >>  template <class _T1, class _T2>
> >>  struct _LIBCPP_VISIBLE pair
> >> @@ -221,7 +224,7 @@
> >>     // pair(const pair&) = default;
> >>     // pair(pair&&) = default;
> >>
> >> -    _LIBCPP_INLINE_VISIBILITY pair() : first(), second() {}
> >> +    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(),
> second() {}
> >>
> >>     _LIBCPP_INLINE_VISIBILITY pair(const _T1& __x, const _T2& __y)
> >>         : first(__x), second(__y) {}
> >>
> >> Modified: libcxx/trunk/src/utility.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/utility.cpp?rev=153968&r1=153967&r2=153968&view=diff
> >>
> ==============================================================================
> >> --- libcxx/trunk/src/utility.cpp (original)
> >> +++ libcxx/trunk/src/utility.cpp Tue Apr  3 16:09:48 2012
> >> @@ -11,6 +11,8 @@
> >>
> >>  _LIBCPP_BEGIN_NAMESPACE_STD
> >>
> >> +#ifdef _LIBCPP_HAS_NO_CONSTEXPR
> >>  const piecewise_construct_t piecewise_construct = {};
> >> +#endif
> >>
> >>  _LIBCPP_END_NAMESPACE_STD
> >
> > This seems dangerous: we don't want the ABI of libc++ to depend on
> > _LIBCPP_HAS_NO_CONSTEXPR.
> >
> > -Eli
>
> Agreed.  I have not yet built a constexpr enabled clang.  Once I do I will
> investigate the best way to handle this.
>
> Howard
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120403/10892bb9/attachment.html>


More information about the cfe-commits mailing list