Skip to content

concept proxiable potentially depend on itself when using facade_aware_overload_t #254

@mingxwa

Description

@mingxwa

The following code should compile, but it won't.

#include "proxy.h"

template <class It, class F>
bool operator==(const It& it, const pro::proxy<F>& rhs) noexcept
    requires(!std::is_same_v<It, pro::proxy<F>>) {
  return typeid(It) == proxy_typeid(rhs) && it == proxy_cast<const It&>(rhs);
}
template <class F>
using SelfComparisonOverload = bool(const pro::proxy<F>& rhs) const noexcept;

template <class T>
struct Iterator : pro::facade_builder
    ::support_direct_rtti
    ::add_direct_convention<pro::operator_dispatch<"++">, void() noexcept>
    ::add_direct_convention<pro::operator_dispatch<"!=">, pro::facade_aware_overload_t<SelfComparisonOverload>>
    ::add_convention<pro::implicit_conversion_dispatch, T&() const noexcept>
    ::build {};

int main() {
  int a[3];
  pro::proxy<Iterator<int>> p = a;  // <-- Won't compile
}

Error message from Clang:

In file included from 1.cc:1:
proxy.h:757:5: error: satisfaction of constraint 'details::facade_traits<F>::template conv_applicable_ptr<P>' depends on itself
  757 |     details::facade_traits<F>::template conv_applicable_ptr<P> &&
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:757:5: note: while substituting template arguments into constraint expression here
  757 |     details::facade_traits<F>::template conv_applicable_ptr<P> &&
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:819:11: note: while checking the satisfaction of concept 'proxiable<int, Iterator<int>>' requested here
  819 |           proxiable<std::decay_t<P>, F> &&
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:819:11: note: while substituting template arguments into constraint expression here
  819 |           proxiable<std::decay_t<P>, F> &&
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:1995:1: note: while checking constraint satisfaction for template 'proxy<Iterator<int>>' required here
 1995 | ___PRO_BINARY_OP_DISPATCH_IMPL(!=)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:1936:5: note: expanded from macro '___PRO_BINARY_OP_DISPATCH_IMPL'
 1936 |     ___PRO_LHS_OP_DISPATCH_IMPL(BINARY, __VA_ARGS__) \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:1898:7: note: expanded from macro '___PRO_LHS_OP_DISPATCH_IMPL'
 1898 |       ___PRO_LHS_##TYPE##_OP_DISPATCH_BODY_IMPL(__VA_ARGS__) \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<scratch space>:60:1: note: expanded from here
   60 | ___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL
      | ^
proxy.h:1891:13: note: expanded from macro '___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL'
 1891 |             std::forward<T>(self) __VA_ARGS__ std::forward<Arg>(arg))
      |             ^~~
proxy.h:1215:57: note: expanded from macro '___PRO_DIRECT_FUNC_IMPL'
 1215 |     noexcept(noexcept(__VA_ARGS__)) requires(requires { __VA_ARGS__; }) \
      |                                                         ^~~~~~~~~~~
proxy.h:1995:1: note: in instantiation of function template specialization 'pro::proxy<Iterator<int>>::proxy<const int &>' requested here
proxy.h:1936:5: note: expanded from macro '___PRO_BINARY_OP_DISPATCH_IMPL'
 1936 |     ___PRO_LHS_OP_DISPATCH_IMPL(BINARY, __VA_ARGS__) \
      |     ^
proxy.h:1898:7: note: expanded from macro '___PRO_LHS_OP_DISPATCH_IMPL'
 1898 |       ___PRO_LHS_##TYPE##_OP_DISPATCH_BODY_IMPL(__VA_ARGS__) \
      |       ^
<scratch space>:60:1: note: expanded from here
   60 | ___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL
      | ^
proxy.h:1891:13: note: expanded from macro '___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL'
 1891 |             std::forward<T>(self) __VA_ARGS__ std::forward<Arg>(arg))
      |             ^
proxy.h:1995:1: note: (skipping 39 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
proxy.h:1936:5: note: expanded from macro '___PRO_BINARY_OP_DISPATCH_IMPL'
 1936 |     ___PRO_LHS_OP_DISPATCH_IMPL(BINARY, __VA_ARGS__) \
      |     ^
proxy.h:1898:7: note: expanded from macro '___PRO_LHS_OP_DISPATCH_IMPL'
 1898 |       ___PRO_LHS_##TYPE##_OP_DISPATCH_BODY_IMPL(__VA_ARGS__) \
      |       ^
<scratch space>:60:1: note: expanded from here
   60 | ___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL
      | ^
proxy.h:1891:13: note: expanded from macro '___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL'
 1891 |             std::forward<T>(self) __VA_ARGS__ std::forward<Arg>(arg))
      |             ^
proxy.h:757:5: note: while substituting template arguments into constraint expression here
  757 |     details::facade_traits<F>::template conv_applicable_ptr<P> &&
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:819:11: note: while checking the satisfaction of concept 'proxiable<int *, Iterator<int>>' requested here
  819 |           proxiable<std::decay_t<P>, F> &&
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:819:11: note: while substituting template arguments into constraint expression here
  819 |           proxiable<std::decay_t<P>, F> &&
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.cc:21:29: note: while checking constraint satisfaction for template 'proxy<Iterator<int>>' required here
   21 |   pro::proxy<Iterator<int>> p = a;  // <-- Won't compile
      |                             ^
1.cc:21:29: note: in instantiation of function template specialization 'pro::proxy<Iterator<int>>::proxy<int (&)[3]>' requested here
In file included from 1.cc:1:
proxy.h:757:5: error: satisfaction of constraint 'details::facade_traits<F>::template conv_applicable_ptr<P>' depends on itself
  757 |     details::facade_traits<F>::template conv_applicable_ptr<P> &&
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:757:5: note: while substituting template arguments into constraint expression here
  757 |     details::facade_traits<F>::template conv_applicable_ptr<P> &&
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:819:11: note: while checking the satisfaction of concept 'proxiable<int *, Iterator<int>>' requested here
  819 |           proxiable<std::decay_t<P>, F> &&
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:819:11: note: while substituting template arguments into constraint expression here
  819 |           proxiable<std::decay_t<P>, F> &&
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:1995:1: note: while checking constraint satisfaction for template 'proxy<Iterator<int>>' required here
 1995 | ___PRO_BINARY_OP_DISPATCH_IMPL(!=)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:1936:5: note: expanded from macro '___PRO_BINARY_OP_DISPATCH_IMPL'
 1936 |     ___PRO_LHS_OP_DISPATCH_IMPL(BINARY, __VA_ARGS__) \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:1898:7: note: expanded from macro '___PRO_LHS_OP_DISPATCH_IMPL'
 1898 |       ___PRO_LHS_##TYPE##_OP_DISPATCH_BODY_IMPL(__VA_ARGS__) \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<scratch space>:60:1: note: expanded from here
   60 | ___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL
      | ^
proxy.h:1891:13: note: expanded from macro '___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL'
 1891 |             std::forward<T>(self) __VA_ARGS__ std::forward<Arg>(arg))
      |             ^~~
proxy.h:1215:57: note: expanded from macro '___PRO_DIRECT_FUNC_IMPL'
 1215 |     noexcept(noexcept(__VA_ARGS__)) requires(requires { __VA_ARGS__; }) \
      |                                                         ^~~~~~~~~~~
proxy.h:1995:1: note: in instantiation of function template specialization 'pro::proxy<Iterator<int>>::proxy<int *const &>' requested here
proxy.h:1936:5: note: expanded from macro '___PRO_BINARY_OP_DISPATCH_IMPL'
 1936 |     ___PRO_LHS_OP_DISPATCH_IMPL(BINARY, __VA_ARGS__) \
      |     ^
proxy.h:1898:7: note: expanded from macro '___PRO_LHS_OP_DISPATCH_IMPL'
 1898 |       ___PRO_LHS_##TYPE##_OP_DISPATCH_BODY_IMPL(__VA_ARGS__) \
      |       ^
<scratch space>:60:1: note: expanded from here
   60 | ___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL
      | ^
proxy.h:1891:13: note: expanded from macro '___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL'
 1891 |             std::forward<T>(self) __VA_ARGS__ std::forward<Arg>(arg))
      |             ^
proxy.h:1995:1: note: (skipping 17 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
proxy.h:1936:5: note: expanded from macro '___PRO_BINARY_OP_DISPATCH_IMPL'
 1936 |     ___PRO_LHS_OP_DISPATCH_IMPL(BINARY, __VA_ARGS__) \
      |     ^
proxy.h:1898:7: note: expanded from macro '___PRO_LHS_OP_DISPATCH_IMPL'
 1898 |       ___PRO_LHS_##TYPE##_OP_DISPATCH_BODY_IMPL(__VA_ARGS__) \
      |       ^
<scratch space>:60:1: note: expanded from here
   60 | ___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL
      | ^
proxy.h:1891:13: note: expanded from macro '___PRO_LHS_BINARY_OP_DISPATCH_BODY_IMPL'
 1891 |             std::forward<T>(self) __VA_ARGS__ std::forward<Arg>(arg))
      |             ^
proxy.h:757:5: note: while substituting template arguments into constraint expression here
  757 |     details::facade_traits<F>::template conv_applicable_ptr<P> &&
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:819:11: note: while checking the satisfaction of concept 'proxiable<int *, Iterator<int>>' requested here
  819 |           proxiable<std::decay_t<P>, F> &&
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.h:819:11: note: while substituting template arguments into constraint expression here
  819 |           proxiable<std::decay_t<P>, F> &&
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.cc:21:29: note: while checking constraint satisfaction for template 'proxy<Iterator<int>>' required here
   21 |   pro::proxy<Iterator<int>> p = a;  // <-- Won't compile
      |                             ^
1.cc:21:29: note: in instantiation of function template specialization 'pro::proxy<Iterator<int>>::proxy<int (&)[3]>' requested here
1.cc:21:29: error: no viable conversion from 'int[3]' to 'pro::proxy<Iterator<int>>'
   21 |   pro::proxy<Iterator<int>> p = a;  // <-- Won't compile
      |                             ^   ~
proxy.h:789:3: note: candidate constructor not viable: no known conversion from 'int[3]' to 'std::nullptr_t' for 1st argument
  789 |   proxy(std::nullptr_t) noexcept : proxy() {}
      |   ^     ~~~~~~~~~~~~~~
proxy.h:801:3: note: candidate constructor not viable: no known conversion from 'int[3]' to 'proxy<Iterator<int>> &&' for 1st argument
  801 |   proxy(proxy&& rhs)
      |   ^     ~~~~~~~~~~~
proxy.h:817:3: note: candidate template ignored: constraints not satisfied [with P = int (&)[3]]
  817 |   proxy(P&& ptr) noexcept(std::is_nothrow_constructible_v<std::decay_t<P>, P>)
      |   ^
proxy.h:819:11: note: because substituted constraint expression is ill-formed: constraint depends on a previously diagnosed expression
  819 |           proxiable<std::decay_t<P>, F> &&
      |           ^
proxy.h:790:3: note: candidate constructor not viable: constraints not satisfied
  790 |   proxy(const proxy&) noexcept requires(F::constraints.copyability ==
      |   ^
proxy.h:790:41: note: because 'Iterator<int>::constraints.copyability == constraint_level::trivial' evaluated to false
  790 |   proxy(const proxy&) noexcept requires(F::constraints.copyability ==
      |                                         ^
proxy.h:792:3: note: candidate constructor not viable: constraints not satisfied
  792 |   proxy(const proxy& rhs)
      |   ^
proxy.h:794:16: note: because 'Iterator<int>::constraints.copyability == constraint_level::nontrivial' evaluated to false
  794 |       requires(F::constraints.copyability == constraint_level::nontrivial ||
      |                ^
proxy.h:795:11: note: and 'Iterator<int>::constraints.copyability == constraint_level::nothrow' evaluated to false
  795 |           F::constraints.copyability == constraint_level::nothrow) {
      |           ^
proxy.h:823:12: note: explicit constructor is not a candidate
  823 |   explicit proxy(std::in_place_type_t<P>, Args&&... args)
      |            ^
3 errors generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions