Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P0848R3 is not supported #40

Open
Myriachan opened this issue Dec 5, 2019 · 1 comment
Open

P0848R3 is not supported #40

Myriachan opened this issue Dec 5, 2019 · 1 comment

Comments

@Myriachan
Copy link

This part of concepts doesn't work:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0848r3.html

Both aspects don't work: Clang rejects Meow<std::string> because std::string doesn't match the requirements of the first constructor, even though it does match the second. Also, Clang fails the second static_assert.

#include <type_traits>
#include <string>

template <typename T> struct Meow {
	Meow() requires (std::is_trivially_default_constructible_v<T>) = default;
	Meow() requires (!std::is_trivially_default_constructible_v<T>) { }
	~Meow() requires (std::is_trivially_destructible_v<T>) = default;
	~Meow() requires (!std::is_trivially_destructible_v<T>) { }
	Meow &operator =(const Meow &) requires (std::is_trivially_copy_assignable_v<T>) = default;
	Meow &operator =(const Meow &) requires (!std::is_trivially_copy_assignable_v<T>) {
		return *this;
	}
};

int main() {
	Meow<int> test1;
	Meow<std::string> test2;
	static_assert(std::is_trivially_copyable_v<decltype(test1)>);
	static_assert(!std::is_trivially_copyable_v<decltype(test2)>);
}
<source>:17:20: error: invalid reference to function '~Meow': constraints not satisfied
        Meow<std::string> test2;
                          ^
<source>:7:20: note: because 'std::is_trivially_destructible_v<std::__1::basic_string<char> >' evaluated to false
        ~Meow() requires (std::is_trivially_destructible_v<T>) = default;
                          ^
<source>:18:5: error: static_assert failed due to requirement 'std::is_trivially_copyable_v<Meow<int> >'
    static_assert(std::is_trivially_copyable_v<decltype(test1)>);
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
@Myriachan
Copy link
Author

I mean the first static_assert not second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant