fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. namespace vector
  5. {
  6. class float3
  7. {
  8. public:
  9. float x,y,z;
  10.  
  11. typedef float float3::*member_type;
  12.  
  13. public:
  14. float3(float x,float y,float z):x(x),y(y),z(z)
  15. {}
  16.  
  17. float3 operator()(member_type x,member_type y,member_type z)
  18. {
  19. return float3(*this.*x,*this.*y,*this.*z);
  20. }
  21.  
  22. };
  23.  
  24. static constexpr float float3::*X=&float3::x;
  25. static constexpr float float3::*Y=&float3::y;
  26. static constexpr float float3::*Z=&float3::z;
  27.  
  28. }
  29.  
  30. int main() {
  31. // your code goes here
  32. using namespace vector;
  33. float3 a(1,2,3);
  34. auto b=a(Y,Z,X);
  35. cout<<b.x<<b.y<<b.z<<endl;
  36. return 0;
  37. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
231