Skip to content

Instantly share code, notes, and snippets.

@mjcarroll
Created April 7, 2020 18:01
Show Gist options
  • Save mjcarroll/b4c04c1f92d5b7362d11851bd442ff91 to your computer and use it in GitHub Desktop.
Save mjcarroll/b4c04c1f92d5b7362d11851bd442ff91 to your computer and use it in GitHub Desktop.
#include "Point.h"
int main(int argc, char** argv)
{
Point p;
}
#include "Point_build.h"
int main(int argc, char** argv)
{
auto p = Point::build().set_x(0.0).set_y(0.0).set_z(0.0);
}
#ifndef POINT_H_
#define POINT_H_
class Point
{
public:
class build;
double x;
double y;
double z;
};
#endif
#ifndef POINT_BUILD_H_
#define POINT_BUILD_H_
#include "Point.h"
#include <utility>
class Init_Point_Z
{
public:
explicit
Init_Point_Z(const Point& msg) : msg_(msg) {}
Point
set_z(double val)
{
msg_.z = std::move(val);
return std::move(msg_);
}
private:
Point msg_;
};
class Init_Point_Y
{
public:
explicit
Init_Point_Y(const Point& msg) : msg_(msg) {}
Init_Point_Z
set_y(double val)
{
msg_.y = std::move(val);
return Init_Point_Z(msg_);
}
private:
Point msg_;
};
class Point::build
{
public:
build(){}
Init_Point_Y
set_x(double val)
{
msg_.x = std::move(val);
return Init_Point_Y(msg_);
}
private:
Point msg_;
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment