Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/concepts/fn10.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
line wrap: on
line source
// { dg-do compile { target c++17 } } // { dg-options "-fconcepts" } // Test that constraint satisfaction checks work even when // processing template declarations. namespace std { struct ostream { }; ostream cout; template<typename T> auto begin(T& t) -> decltype(t.begin()) { return t.begin(); } template<typename T> auto begin(T const& t) -> decltype(t.begin()) { return t.begin(); } template<typename T> auto end(T& t) -> decltype(t.end()) { return t.end(); } template<typename T> auto end(T const& t) -> decltype(t.end()) { return t.end(); } } // namespace std template <typename T> concept bool Float() { return __is_same_as( T, float ); } template <typename T> constexpr decltype(auto) project( T t ) { return t; } template <typename T> concept bool Concept() { return requires( T t ) { requires Float<decltype( project(t) )>(); }; } template <Concept E, Concept F> constexpr decltype(auto) operator<<( E&& e, F&& f ) {} template <Concept T> void foo( T t ) { // Try to resolve operator<< from within a template context but // with non-dependent arguments. We need to ensure that template // processing is turned off whenever checking for satisfaction. std::cout << "OK"; // { dg-error "no match" } } template <typename R> concept bool Range() { return requires( R r ) { requires __is_same_as( decltype(std::begin(r)), decltype(std::end(r)) ); }; } struct A { A() = default; A( const A& ) = default; // Derivation from this class forces the instantiation of // this constructor, which results in the __is_same_as type // trait above to become error_mark_node in this declaration. template <Range R> explicit A( R&& r ) { } }; struct C : A { C() = default; C( const C& ) = default; }; int main() { C c; // OK return 0; }