c++ - How to get reference to an element of a std::tuple? -


you can value of nth element of std::tuple using std::get<n>(tuple). need pass 1 element of tuple reference function.

how reference element of std::tuple?

std::get returns reference(either const or non-const), works:

void fun(int &a) {     = 15; }  void test() {     std::tuple<int, char> foo{ 12, 'a' };     fun(std::get<0>(foo)); } 

demo here.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -