Architecture Diagram
┌───────────────────────────────┐
│ std::pair │
├───────────────┬───────────────┤
│ .first (T1) │ .second (T2) │
└───────────────┴───────────────┘┌───────────────────────────────┐
│ std::pair │
├───────────────┬───────────────┤
│ .first (T1) │ .second (T2) │
└───────────────┴───────────────┘std::make_pair(v1, v2): Deduces types automatically.std::pair{1, "Admin"} .#include <iostream>
#include <utility>
#include <string>
std::pair<bool, std::string> authenticateUser(const std::string& user, const std::string& pass) {
if (user == "admin" && pass == "secret123") {
return {true, "Authentication successful (Role: SuperAdmin)"};
}
return {false, "Invalid username or password"};
}
int main() {
// Structured Binding (C++17)
auto [success, message] = authenticateUser("admin", "secret123");
if (success) {
std::cout << "[SUCCESS] " << message << "\n";
} else {
std::cout << "[DENIED] " << message << "\n";
}
std::pair<int, int> coordinates = std::make_pair(1920, 1080);
std::cout << "Resolution: " << coordinates.first << "x" << coordinates.second << "\n";
return 0;
}