diff --git a/CMakeLists.txt b/CMakeLists.txt index e9bd681..b18ffa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(lilfbtf5 VERSION 0.1.14) +project(lilfbtf5 VERSION 0.1.15) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/include/lilfbtf/random.h b/include/lilfbtf/random.h new file mode 100644 index 0000000..cce3cca --- /dev/null +++ b/include/lilfbtf/random.h @@ -0,0 +1,45 @@ +#pragma once +/* + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LILFBTF5_RANDOM_H +#define LILFBTF5_RANDOM_H + +#include +#include + +namespace fb +{ + class random + { + private: + blt::u64 seed; + std::mt19937_64 engine; + public: + explicit random(blt::u64 seed); + + void reset(); + bool choice(); + + float random_float(float min = 0, float max = 1); + double random_double(double min = 0, double max = 1); + blt::u64 random_long(blt::u64 min = 0, blt::u64 max = 1); + blt::i32 random_int(blt::i32 min = 0, blt::i32 max = 1); + }; +} + +#endif //LILFBTF5_RANDOM_H diff --git a/include/lilfbtf/tree.h b/include/lilfbtf/tree.h new file mode 100644 index 0000000..13754b8 --- /dev/null +++ b/include/lilfbtf/tree.h @@ -0,0 +1,27 @@ +#pragma once +/* + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LILFBTF5_TREE_H +#define LILFBTF5_TREE_H + +namespace fb +{ + +} + +#endif //LILFBTF5_TREE_H diff --git a/libs/BLT b/libs/BLT index 1abd321..9bba525 160000 --- a/libs/BLT +++ b/libs/BLT @@ -1 +1 @@ -Subproject commit 1abd3214be23289b26f4cf2329c4a58c0c7be04b +Subproject commit 9bba525b1f33495a68c43fa1f66c0a239220e68c diff --git a/src/random.cpp b/src/random.cpp new file mode 100644 index 0000000..9a863f8 --- /dev/null +++ b/src/random.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include + +namespace fb +{ + + random::random(blt::u64 seed): seed(seed), engine(seed) + { + + } + + void random::reset() + { + engine.seed(seed); + } + + bool random::choice() + { + static std::uniform_int_distribution dist(0, 1); + return dist(engine); + } + + float random::random_float(float min, float max) + { + std::uniform_real_distribution dist(min, max); + return dist(engine); + } + + double random::random_double(double min, double max) + { + std::uniform_real_distribution dist(min, max);\ + return dist(engine); + } + + blt::u64 random::random_long(blt::u64 min, blt::u64 max) + { + std::uniform_int_distribution dist(min, max); + return dist(engine); + } + + blt::i32 random::random_int(blt::i32 min, blt::i32 max) + { + std::uniform_int_distribution dist(min, max); + return dist(engine); + } +} \ No newline at end of file diff --git a/src/tree.cpp b/src/tree.cpp new file mode 100644 index 0000000..ca6b3c4 --- /dev/null +++ b/src/tree.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include + +namespace fb +{ + + + +} \ No newline at end of file diff --git a/tests/include/lilfbtf/test5.h b/tests/include/lilfbtf/test5.h new file mode 100644 index 0000000..03e8cb9 --- /dev/null +++ b/tests/include/lilfbtf/test5.h @@ -0,0 +1,27 @@ +#pragma once +/* + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LILFBTF5_TEST5_H +#define LILFBTF5_TEST5_H + +namespace fb +{ + void test5(); +} + +#endif //LILFBTF5_TEST5_H diff --git a/tests/src/main.cpp b/tests/src/main.cpp index b76b9dc..91bf4de 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -7,6 +7,7 @@ #include #include #include "blt/profiling/profiler_v2.h" +#include "lilfbtf/test5.h" struct data { float f; @@ -50,7 +51,8 @@ int main(int argc, const char** argv) { //fb::test2(); //fb::test3(); - fb::test4(); + //fb::test4(); + fb::test5(); BLT_PRINT_PROFILE("Tree Construction"); BLT_PRINT_PROFILE("Tree Evaluation"); diff --git a/tests/src/tests5.cpp b/tests/src/tests5.cpp new file mode 100644 index 0000000..ca14fef --- /dev/null +++ b/tests/src/tests5.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include +#include + +namespace fb +{ + + struct destoryable + { + std::string name; + destoryable(std::string_view name): name(name) + { + BLT_INFO("Called constructor %s", this->name.c_str()); + } + + ~destoryable() + { + BLT_INFO("Called destructor %s", name.c_str()); + } + }; + + void test5() + { + blt::unsafe::any_t_union any_construct(destoryable{"construct"}); + + blt::unsafe::any_t_union any_assignment = 5; + + any_assignment = destoryable{"assignment"}; + + any_construct = destoryable{"copy"}; + + // copy + any_assignment = any_construct; + + any_assignment = destoryable{"move"}; + + any_construct = std::move(any_assignment); + + any_assignment = 5; + } + +} \ No newline at end of file