public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67148] [concepts] Failed concept check when indirecting through a constrained trait
[not found] <bug-67148-4@http.gcc.gnu.org/bugzilla/>
@ 2015-08-07 20:25 ` eric.niebler at gmail dot com
2015-08-09 2:03 ` Casey at Carter dot net
1 sibling, 0 replies; 2+ messages in thread
From: eric.niebler at gmail dot com @ 2015-08-07 20:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67148
--- Comment #1 from Eric Niebler <eric.niebler at gmail dot com> ---
If I replace the variadic Same concept with the binary one below, the problem
goes away.
template<class T, class U>
concept bool Same() {
return __is_same_as(T,U);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/67148] [concepts] Failed concept check when indirecting through a constrained trait
[not found] <bug-67148-4@http.gcc.gnu.org/bugzilla/>
2015-08-07 20:25 ` [Bug c++/67148] [concepts] Failed concept check when indirecting through a constrained trait eric.niebler at gmail dot com
@ 2015-08-09 2:03 ` Casey at Carter dot net
1 sibling, 0 replies; 2+ messages in thread
From: Casey at Carter dot net @ 2015-08-09 2:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67148
--- Comment #2 from Casey Carter <Casey at Carter dot net> ---
Here's a somewhat minimized test case that illustrates that overload resolution
works correctly, but matching partial specializations of a class template or
variable template does not:
template <bool Value>
struct bool_ {
static constexpr bool value {Value};
};
using true_type = bool_<true>;
using false_type = bool_<false>;
template <class...> struct all_same : true_type {};
template <class T, class...Rest>
struct all_same<T, T, Rest...> : all_same<T, Rest...> {};
template <class T, class U, class...Rest>
struct all_same<T, U, Rest...> : false_type {};
template <class...Ts>
concept bool Same() {
return all_same<Ts...>::value;
}
template <class F, class...Args>
concept bool Function() {
return requires (F& f, Args&&...args) {
requires Same<int, decltype(f((Args&&)args...))>();
};
}
template <class, class...>
constexpr bool function() { return false; }
Function{F, ...Args}
constexpr bool function() { return true; }
template <class, class...>
constexpr bool func_v = false;
Function{F, ...Args}
constexpr bool func_v<F, Args...> = true;
template <class, class...>
struct is_function : false_type {};
Function{F, ...Args}
struct is_function<F, Args...> : true_type {};
struct plus { int operator()(int) const; };
static_assert(function<::plus, int>()); // Fine
static_assert(func_v<::plus, int>); // Error
static_assert(is_function<::plus, int>::value); // Error
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-09 2:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-67148-4@http.gcc.gnu.org/bugzilla/>
2015-08-07 20:25 ` [Bug c++/67148] [concepts] Failed concept check when indirecting through a constrained trait eric.niebler at gmail dot com
2015-08-09 2:03 ` Casey at Carter dot net
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).