Commit 7697d3a8 authored by jonasseidel's avatar jonasseidel
Browse files

common type

parent 34a58031
#define CMP_EPS 1e-10
#include "integrality.h"
std::ostream& operator<<(std::ostream& os, const integrality& integr){
switch(integr){
case Continuous:
os << "Continuous";
break;
case Integral:
os << "Integral";
break;
default:
throw std::runtime_error("invalid integrality type");
}
return os;
}
std::istream& operator>>(std::istream& is, integrality& integr){
std::string curr;
is >> curr;
if(curr == "Continuous"){
integr = Continuous;
}else if(curr == "Integral"){
integr = Integral;
}else{
throw std::invalid_argument("invalid integrality");
}
return is;
}
#ifndef INTEGRALITY_H
#define INTEGRALITY_H
#include <iostream>
enum integrality : bool {Continuous = false, Integral = true};
std::ostream& operator<<(std::ostream& os, const integrality& integr);
std::istream& operator>>(std::istream& is, integrality& integr);
#endif
#include "opt_dir.h"
std::ostream& operator<<(std::ostream& os, const opt_dir& direction){
switch(direction){
case max:
os << "max";
break;
case fix:
os << "fix";
break;
case min:
os << "min";
break;
default:
throw std::runtime_error("invalid direction");
}
return os;
}
std::istream& operator>>(std::istream& is, opt_dir& direction){
std::string curr;
is >> curr;
if(curr == "max"){
direction = max;
}else if(curr == "fix"){
direction = fix;
}else if(curr == "min"){
direction = min;
}else{
throw std::invalid_argument("invalid direction");
}
return is;
}
#ifndef OPT_DIR_H
#define OPT_DIR_H
#include <iostream>
enum opt_dir : int {max = 1, fix = 0, min = -1};
std::ostream& operator<<(std::ostream& os, const opt_dir& direction);
std::istream& operator>>(std::istream& is, opt_dir& direction);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment