Libmini is designed to bring simple quality of life features from later versions of C++ into C++98.
#include "pointer.hpp"
#include <iostream>
int main() {
mini::uniqueptr<int> myUniquePtr = mini::make_unique<int>();
*myUniquePtr = 10;
std::cout << "The value is: " << *myUniquePtr << std::endl;
return 0;
}
#include "array.hpp"
#include <iostream>
int main() {
int myArray[5] = {1, 2, 3, 4, 5};
std::cout << "Size of myArray is: " << mini::size(myArray) << std::endl;
return 0;
}
#include "color.hpp"
#include <iostream>
int main() {
std::cout << color::RED << "This text is red." << color::RESET << std::endl;
std::cout << color::GREEN << "This text is green." << color::RESET << std::endl;
std::cout << color::YELLOW << "This text is yellow." << color::RESET << std::endl;
std::cout << color::BLUE << "This text is blue." << color::RESET << std::endl;
std::cout << color::MAGENTA << "This text is magenta." << color::RESET << std::endl;
std::cout << color::CYAN << "This text is cyan." << color::RESET << std::endl;
std::cout << color::WHITE << "This text is white." << color::RESET << std::endl;
// Background colors
std::cout << color::RED_BG << "This has a red background." << color::RESET << std::endl;
std::cout << color::GREEN_BG << "This has a green background." << color::RESET << std::endl;
return 0;
}
Note that this is moslty syntactic sugar for cases where your are asked to follow the Orthodox Canonical Class form to fanatical levels :)
#include "define.hpp"
#include <iostream>
class MyClass {
public:
MyClass() DELETE; // Delete the default constructor
// Define a constructor with parameters
MyClass(int value) : value_(value) {
std::cout << "MyClass constructed with value: " << value_ << std::endl;
}
private:
int value_;
};
int main() {
// MyClass myObject; // This line will cause a compile-time error
MyClass myObject(10); // Correct way to instantiate MyClass
return 0;
}