captureString(std::string(),x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
captureString(local_string,x);
captureRValString(std::move(local_string),x);
captureRValString(std::string(),x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
captureRValStringView(std::string(),x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
captureRValStringView(getLifetimeBoundView(std::string()),x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
captureStringView(getLifetimeBoundString(std::string()),x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
captureStringView(getLifetimeBoundString(getLifetimeBoundView(std::string())),x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
capturePointer(getLifetimeBoundPointer(std::string()),x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
captureVector({1,2,3},x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
captureVector(std::vector<int>{},x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
std::vector<int>local_vector;
captureVector(local_vector,x);
intlocal_array[2];
captureArray(local_array,x);
captureInitList({1,2},x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
captureInitList(getLifetimeBoundInitList({1,2}),x);// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
captureByGlobal(std::string());// expected-warning {{object whose reference is captured will be destroyed at the end of the full-expression}}
captureByGlobal(getLifetimeBoundView(std::string()));// expected-warning {{object whose reference is captured will be destroyed at the end of the full-expression}}
captureByGlobal(local_string);
captureByGlobal(local_string_view);
// capture by unknown.
captureByUnknown(std::string());// expected-warning {{object whose reference is captured will be destroyed at the end of the full-expression}}
captureByUnknown(getLifetimeBoundView(std::string()));// expected-warning {{object whose reference is captured will be destroyed at the end of the full-expression}}
s.captureInt(1);// expected-warning {{object whose reference is captured by 's' will be destroyed at the end of the full-expression}}
s.captureView(std::string());// expected-warning {{object whose reference is captured by 's' will be destroyed at the end of the full-expression}}
s.captureView(getLifetimeBoundView(std::string()));// expected-warning {{object whose reference is captured by 's' will be destroyed at the end of the full-expression}}
s.captureView(getLifetimeBoundString(std::string()));// expected-warning {{object whose reference is captured by 's' will be destroyed at the end of the full-expression}}
captureDefaultArg(x,std::string("temp"));// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
captureDefaultArg(x,getLifetimeBoundView(std::string()));// expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
set_of_int.insert(1);// expected-warning {{object whose reference is captured by 'set_of_int' will be destroyed at the end of the full-expression}}
MySet<std::string_view>set_of_sv;
set_of_sv.insert(std::string());// expected-warning {{object whose reference is captured by 'set_of_sv' will be destroyed at the end of the full-expression}}
vector_of_view.push_back(std::string());// expected-warning {{object whose reference is captured by 'vector_of_view' will be destroyed at the end of the full-expression}}
vector_of_view.push_back(getLifetimeBoundView(std::string()));// expected-warning {{object whose reference is captured by 'vector_of_view' will be destroyed at the end of the full-expression}}
MyVector<conststd::string*>vector_of_pointer;
vector_of_pointer.push_back(getLifetimeBoundPointer(std::string()));// expected-warning {{object whose reference is captured by 'vector_of_pointer' will be destroyed at the end of the full-expression}}
vector_of_pointer.push_back(getLifetimeBoundPointer(*getLifetimeBoundPointer(std::string())));// expected-warning {{object whose reference is captured by 'vector_of_pointer' will be destroyed at the end of the full-expression}}
vector_of_my_view.push_back(std::string{});// expected-warning {{object whose reference is captured by 'vector_of_my_view' will be destroyed at the end of the full-expression}}
vector_of_my_view.push_back(getLifetimeBoundView(std::string{}));// expected-warning {{object whose reference is captured by 'vector_of_my_view' will be destroyed at the end of the full-expression}}
vector_of_my_view.push_back(getLifetimeBoundString(getLifetimeBoundView(std::string{})));// expected-warning {{object whose reference is captured by 'vector_of_my_view' will be destroyed at the end of the full-expression}}
vector_of_view.push_back(getOptionalS().value());// expected-warning {{object whose reference is captured by 'vector_of_view' will be destroyed at the end of the full-expression}}
views.push_back(std::string());// expected-warning {{object whose reference is captured by 'views' will be destroyed at the end of the full-expression}}
views.insert(views.begin(),
std::string());// expected-warning {{object whose reference is captured by 'views' will be destroyed at the end of the full-expression}}
views.push_back(getLifetimeBoundView(std::string()));// expected-warning {{object whose reference is captured by 'views' will be destroyed at the end of the full-expression}}
pointers.push_back(getLifetimeBoundPointer(std::string()));// expected-warning {{object whose reference is captured by 'pointers' will be destroyed at the end of the full-expression}}
pointers.push_back(&local);
}
namespacewith_span{
// Templated view types.
template<typenameT>
struct[[gsl::Pointer]]Span{
Span(conststd::vector<T>&V);
};
voiduse(){
std::vector<Span<int>>spans;
spans.push_back(std::vector<int>{1,2,3});// expected-warning {{object whose reference is captured by 'spans' will be destroyed at the end of the full-expression}}