Hello, I'm a student studying c++.++.
In my project, I need a class with functions similar to the variable in boost.
However, the cost is too high to add boost, so I tried to implement it myself, although it was sloppy.
So I opened the boost variable.hpp and saw it, but I couldn't understand it, so I posted a question like this.
I am curious about the principle of variable and what is the most important c++ grammar for implementing variable!
c++ boost
If you can use C++11 or higher, you can use the triple.
http://www.cplusplus.com/reference/tuple/tuple/
// http://www.cplusplus.com/reference/tuple/tuple/
// // tuple example
#include <iostream> // std::cout
#include <tuple> // std::tuple, std::get, std::tie, std::ignore
int main ()
{
std::tuple<int,char> foo (10,'x');
auto bar = std::make_tuple ("test", 3.1, 14, 'y');
std::get<2>(bar) = 100; // access element
int myint; char mychar;
std::tie (myint, mychar) = foo; // unpack elements
std::tie (std::ignore, std::ignore, myint, mychar) = bar; // unpack (with ignore)
mychar = std::get<3>(bar);
std::get<0>(foo) = std::get<2>(bar);
std::get<1>(foo) = mychar;
std::cout << "foo contains: ";
std::cout << std::get<0>(foo) << ' ';
std::cout << std::get<1>(foo) << '\n';
return 0;
}
1788 Uncaught (inpromise) Error on Electron: An object could not be cloned
1948 I want to connect to the webcam from WSL(ubuntu)
1749 Error in x, y, and format string must not be None
1921 M2 Mac fails to install rbenv install 3.1.3 due to errors
3079 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2026 OneMinuteCode. All rights reserved.