This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3, patch, variant] user-defined operator& and std::variant


Hello,

Following code does not compile,

#include <variant>

namespace n
{
    template<typename T>
    void operator&(T) {}
    struct s{};
}

int main()
{
    std::variant<n::s> v;
    std::get<n::s>(v);
}

error: include/c++/7.0.0/variant:315:4: error: invalid static_cast

diff -r -u a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
--- a/libstdc++-v3/include/std/variant 2016-08-26 13:34:30.823029400 +0300
+++ b/libstdc++-v3/include/std/variant 2016-09-03 18:01:26.431299300 +0300
@@ -312,7 +312,7 @@
       _M_storage() const
       {
  return const_cast<void*>(
-  static_cast<const void*>(&_M_first._M_storage));
+  static_cast<const void*>(std::__addressof(_M_first._M_storage)));
       }

       union


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]