Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of std::optional to pass a std::vector<int> to a functional by reference

I am unclear if the correct code to pass an optional vector of ints to a function by reference is :

void test_func(std::optional<std::vector<int>&> vec)

or

void test_func(std::optional<std::vector<int>>& vec)

Any help much appreciated.

like image 363
oracle3001 Avatar asked Dec 10 '22 04:12

oracle3001


1 Answers

A non-owning pointer is a nullable reference type.

void test_func(std::vector<int>* vec)
like image 55
Yakk - Adam Nevraumont Avatar answered May 12 '23 15:05

Yakk - Adam Nevraumont