diff --git a/ex00/PrintNb.hpp b/ex00/PrintNb.hpp new file mode 100644 index 0000000..f80ac5f --- /dev/null +++ b/ex00/PrintNb.hpp @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* PrintNb.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/04/08 14:30:07 by adjoly #+# #+# */ +/* Updated: 2025/04/08 14:30:36 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include + +template void _printFloat(T nb) { + std::cout << "float: " << static_cast(nb) << "f" << std::endl; +} +template void _printInt(T nb) { + std::cout << "int: " << static_cast(nb) << std::endl; +} +template void _printChar(T nb) { + std::cout << "char: '" << static_cast(nb) << "'" << std::endl; +} +template void _printDouble(T nb) { + std::cout << "double: " << static_cast(nb) << std::endl; +} diff --git a/ex00/ScalarConverter.cpp b/ex00/ScalarConverter.cpp index 2649616..0dce6c1 100644 --- a/ex00/ScalarConverter.cpp +++ b/ex00/ScalarConverter.cpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/03 19:59:17 by adjoly #+# #+# */ -/* Updated: 2025/04/04 11:20:32 by adjoly ### ########.fr */ +/* Updated: 2025/04/08 14:17:44 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,7 +25,6 @@ void _log(std::string emoji, std::string what, std::string who, #endif } - ScalarConverter::ScalarConverter(void) { _log("➕", "ScalarConverter", "", "default constructor called"); } @@ -39,9 +38,10 @@ ScalarConverter::ScalarConverter(const ScalarConverter &cpy) { ScalarConverter::~ScalarConverter(void) { _log("➖", "ScalarConverter", "", "destructor called"); - } +ScalarConverter &ScalarConverter::operator=(const ScalarConverter &) { return *this; } + void ScalarConverter::convert(std::string &s) { } diff --git a/ex00/ScalarConverter.hpp b/ex00/ScalarConverter.hpp index 0759db6..822c9b3 100644 --- a/ex00/ScalarConverter.hpp +++ b/ex00/ScalarConverter.hpp @@ -6,22 +6,36 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/03 19:38:39 by adjoly #+# #+# */ -/* Updated: 2025/04/04 12:12:41 by adjoly ### ########.fr */ +/* Updated: 2025/04/08 14:29:28 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#include #include +#include class ScalarConverter { public: - static void convert(std::string &); - private: - ScalarConverter(void); - ScalarConverter(const ScalarConverter &); - ~ScalarConverter(void); + static void convert(std::string &); - ScalarConverter &operator=(const ScalarConverter &); + private: + ScalarConverter(void); + ScalarConverter(const ScalarConverter &); + ~ScalarConverter(void); + + ScalarConverter &operator=(const ScalarConverter &); + + template void _printFloat(T nb) { + std::cout << "float: " << static_cast(nb) << "f" << std::endl; + } + template void _printInt(T nb) { + std::cout << "int: " << static_cast(nb) << std::endl; + } + template void _printChar(T nb) { + std::cout << "char: '" << static_cast(nb) << "'" << std::endl; + } + template void _printDouble(T nb) { + std::cout << "double: " << static_cast(nb) << std::endl; + } };