This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug c++/71487] New: sorry, unimplemented: mangling offset_ref


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71487

            Bug ID: 71487
           Summary: sorry, unimplemented: mangling offset_ref
           Product: gcc
           Version: 5.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lemonedo at gmail dot com
  Target Milestone: ---

The following C++ code does not compile with GCC 5.3.1.

#include <iostream>
#include <string>

template<class T> T& declval() { return *static_cast<T*>(0); }

template<class F, class T>
struct PropertyMatcher {
   F memfun;
   T expected;

   PropertyMatcher(F memfun, T expected) : memfun(memfun), expected(expected)
{}

   template<class U>
   void operator()(U actual) {
     std::cout << ((actual.*memfun)() == expected) << std::endl;
   }
};

template<class F, class T>
PropertyMatcher<F, T> Property(F memfun, T expected) {
  return PropertyMatcher<F, T>(memfun, expected);
}

template<class T>
auto HasLength(T expected) -> decltype(Property(&std::string::size,
declval<T>())) {
  return Property(&std::string::size, expected);
}

int main() {
  HasLength(3)(std::string("hel"));
}

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