1919#include < string_view>
2020#include < type_traits>
2121#include < utility>
22+ #include < variant>
2223#include < vector>
2324
2425#include " gtest/gtest.h"
@@ -31,6 +32,11 @@ namespace {
3132
3233using ::testing::StaticAssertTypeEq;
3334
35+ template <typename T>
36+ using IsViewAndNotOwner =
37+ std::conjunction<absl::type_traits_internal::IsView<T>,
38+ std::negation<absl::type_traits_internal::IsOwner<T>>>;
39+
3440template <typename T>
3541using IsOwnerAndNotView =
3642 std::conjunction<absl::type_traits_internal::IsOwner<T>,
@@ -50,6 +56,23 @@ static_assert(!IsOwnerAndNotView<std::string_view>::value,
5056static_assert (!IsOwnerAndNotView<std::wstring_view>::value,
5157 " wstring_view is a view, not an owner" );
5258
59+ static_assert (!IsOwnerAndNotView<std::variant<>>::value,
60+ " empty variant is not an owner" );
61+ static_assert (!IsViewAndNotOwner<std::variant<>>::value,
62+ " empty variant is not a view" );
63+
64+ static_assert (IsOwnerAndNotView<std::variant<std::string, std::vector<char >,
65+ std::vector<int >>>::value,
66+ " aggregate of owners is an owner" );
67+ static_assert (
68+ IsViewAndNotOwner<std::variant<std::wstring_view, std::string_view>>::value,
69+ " aggregate of views is an view" );
70+
71+ static_assert (!IsOwnerAndNotView<std::variant<const char *, std::string>>::value,
72+ " variant of mixed-ownership types is not considered an owner" );
73+ static_assert (!IsViewAndNotOwner<std::variant<const char *, std::string>>::value,
74+ " variant of mixed-ownership types is not considered a view" );
75+
5376template <class T , class U >
5477struct simple_pair {
5578 T first;
0 commit comments