Open Zeyd-RJEB opened 1 month ago
#include <variant>
#include <iostream>
#include <stdexcept>
// Define shape structures
struct Circle {
double radius;
};
struct Rectangle {
double width;
double height;
};
struct Triangle {
double base;
double height;
};
// Use std::variant to hold any of the shape types
using Shape = std::variant<Circle, Rectangle, Triangle>;
// Implement Visitor for Area Calculation
struct AreaCalculator {
double operator()(const Circle& circle) const {
return 3.14159 * circle.radius * circle.radius;
}
double operator()(const Rectangle& rectangle) const {
return rectangle.width * rectangle.height;
}
double operator()(const Triangle& triangle) const {
return 0.5 * triangle.base * triangle.height;
}
};
// Perform the calculation using std::visit
double calculateArea(const Shape& shape) {
return std::visit(AreaCalculator{}, shape);
}
// Usage example
int main() {
Shape circle = Circle{5.0};
Shape rectangle = Rectangle{4.0, 6.0};
Shape triangle = Triangle{3.0, 4.0};
std::cout << "Circle area: " << calculateArea(circle) << std::endl;
std::cout << "Rectangle area: " << calculateArea(rectangle) << std::endl;
std::cout << "Triangle area: " << calculateArea(triangle) << std::endl;
return 0;
}
grep '35=D' fix.log | awk -F '|' '{ for(i=1;i<=NF;i++) { if ($i ~ /11=/) print $i }}' | sed 's/11=//' | grep -Fxv -f <(grep '35=8' fix.log | grep '150=F' | awk -F '|' '{ for(i=1;i<=NF;i++) { if ($i ~ /11=/) print $i }}' | sed 's/11=//')