Created
August 17, 2023 17:49
-
-
Save hare1039/5d72901c9432ba8a723b6cb7b9e88a01 to your computer and use it in GitHub Desktop.
some rename test (not tested in productions)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
struct point2d : public std::pair<int, int> | |
{ | |
int& x() { return first; } | |
int& y() { return second; } | |
template <typename ... Args> | |
point2d(Args&& ... args) : pair<int, int>(std::forward<Args>(args)...) {} | |
}; | |
struct point3d : public std::tuple<int, int, int> | |
{ | |
int& x() { return std::get<0>(*this); } | |
int& y() { return std::get<1>(*this); } | |
int& z() { return std::get<2>(*this); } | |
template <typename ... Args> | |
point3d(Args&& ... args) : tuple<int, int, int>(std::forward<Args>(args)...) {} | |
}; | |
int main() | |
{ | |
point2d p1{1, 2}; | |
point2d p2(2, 3); | |
point3d q1{5, 4, 3}; | |
point3d q2(6, 5, 4); | |
std::cout << sizeof(point2d) << " " << (p1 < p2) << "\n"; | |
std::cout << sizeof(point3d) << " " << (q1 < q2) << "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment