public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58569] Compilation error when a class contains multiple std::function
Date: Tue, 01 Oct 2013 08:52:00 -0000	[thread overview]
Message-ID: <bug-58569-4-2OHB4gh8Vx@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58569-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58569

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Argh, yes, I didn't read the diagnostic properly after that last change, sorry!

Corrected:

struct false_type { enum { value=0 }; };
struct true_type { enum { value=1 }; };

template<typename T>
  struct add_rvalue_reference {
    using type = T&&;
  };

template<typename _Tp>
  typename add_rvalue_reference<_Tp>::type declval() noexcept;

template<typename _From, typename _To>
  class is_convertible
  {
     template<typename _To1>
      static void __test_aux(_To1);

    template<typename _From1, typename _To1,
             typename = decltype(__test_aux<_To1>(declval<_From1>()))>
      static true_type
      __test(int);

    template<typename, typename>
      static false_type
      __test(...);

  public:
    typedef decltype(__test<_From, _To>(0)) type;
  };

template<bool B> struct enable_if { typedef void type; };
template<> struct enable_if<false> { };

template<typename _Functor>
  inline _Functor&
  __callable_functor(_Functor& __f)
  { return __f; }

template<typename S> struct Function;

template<typename R, typename... A>
struct Function<R(A...)>
{
  template<typename F>
    using Invoke = decltype(__callable_functor(declval<F&>())
                            (declval<A>()...) );

  template<typename CallRes, typename Res1>
    struct CheckResult
    : is_convertible<CallRes, Res1> { };

  // template<typename CR> struct CheckResult<CR, CR> : true_type { };

  template<typename F>
    using Callable = CheckResult<Invoke<F>, R>;

  template<typename Cond>
    using Requires = typename enable_if<Cond::value>::type;

  template<typename F, typename R = Requires<Callable<F>>>
    Function(F);

  Function();

  R operator()(A...) const;
};

struct foo {
  Function<foo (int)> x;
  Function<foo ()> y;
};

int main() {
  foo a;
}


  parent reply	other threads:[~2013-10-01  8:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-28 20:16 [Bug c++/58569] New: Compilation error when copying class which " pierre.krieger1708 at gmail dot com
2013-09-28 23:53 ` [Bug c++/58569] Compilation error when a class " redi at gcc dot gnu.org
2013-10-01  6:39 ` paolo.carlini at oracle dot com
2013-10-01  7:01 ` redi at gcc dot gnu.org
2013-10-01  7:11 ` daniel.kruegler at googlemail dot com
2013-10-01  7:46 ` redi at gcc dot gnu.org
2013-10-01  7:49 ` daniel.kruegler at googlemail dot com
2013-10-01  8:04 ` redi at gcc dot gnu.org
2013-10-01  8:10 ` redi at gcc dot gnu.org
2013-10-01  8:12 ` redi at gcc dot gnu.org
2013-10-01  8:26 ` redi at gcc dot gnu.org
2013-10-01  8:32 ` daniel.kruegler at googlemail dot com
2013-10-01  8:52 ` redi at gcc dot gnu.org [this message]
2013-10-01  8:57 ` daniel.kruegler at googlemail dot com
2013-10-01  9:17 ` daniel.kruegler at googlemail dot com
2013-10-01 13:01 ` [Bug libstdc++/58569] " paolo.carlini at oracle dot com
2013-10-02 20:22 ` redi at gcc dot gnu.org
2013-10-02 20:22 ` redi at gcc dot gnu.org
2013-10-02 20:23 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-58569-4-2OHB4gh8Vx@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).