main
parent
27ecb2b46d
commit
f573aaf92f
|
@ -27,7 +27,7 @@ macro(compile_options target_name)
|
||||||
sanitizers(${target_name})
|
sanitizers(${target_name})
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
project(blt-gp VERSION 0.5.15)
|
project(blt-gp VERSION 0.5.16)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
|
|
2
lib/blt
2
lib/blt
|
@ -1 +1 @@
|
||||||
Subproject commit 2bac310e55df06a3e378c932afa2a4c2bc2123e7
|
Subproject commit fb092422a82e503d314fc5c99eacb306c29386e8
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
#include <blt/gp/program.h>
|
#include <blt/gp/program.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <blt/std/variant.h>
|
||||||
|
|
||||||
#ifndef BLT_ASSERT_RET
|
#ifndef BLT_ASSERT_RET
|
||||||
#define BLT_ASSERT_RET(expr) if (!(expr)) { return false; }
|
#define BLT_ASSERT_RET(expr) if (!(expr)) { return false; }
|
||||||
|
|
|
@ -26,59 +26,48 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <blt/fs/stream_wrappers.h>
|
#include <blt/fs/stream_wrappers.h>
|
||||||
|
|
||||||
|
struct default_type
|
||||||
struct no_default
|
|
||||||
{
|
{
|
||||||
no_default() = delete;
|
std::string to_string() // NOLINT
|
||||||
|
|
||||||
no_default(int)
|
|
||||||
{
|
{
|
||||||
|
return "Unimplemented";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct not_copyable
|
struct type1 : default_type
|
||||||
{
|
{
|
||||||
not_copyable() = default;
|
std::string to_string() // NOLINT
|
||||||
not_copyable(const not_copyable&) = delete;
|
{
|
||||||
|
return "type1";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct copyable
|
struct type2 : default_type
|
||||||
{
|
{
|
||||||
copyable() = default;
|
std::string to_string() // NOLINT
|
||||||
copyable(const copyable&) = default;
|
{
|
||||||
|
return "type2";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct copyable_nothrow
|
struct type3 : default_type
|
||||||
{
|
{
|
||||||
copyable_nothrow() = default;
|
std::string to_string() // NOLINT
|
||||||
copyable_nothrow(const copyable_nothrow&) noexcept = default;
|
{
|
||||||
|
return "type3";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct not_movable
|
void test()
|
||||||
{
|
{
|
||||||
not_movable() = default;
|
blt::variant_t<type1, type2, type3> some_type1{type1{}};
|
||||||
not_movable(not_movable&&) = delete;
|
blt::variant_t<type1, type2, type3> some_type2{type2{}};
|
||||||
};
|
blt::variant_t<type1, type2, type3> some_type3{type3{}};
|
||||||
|
|
||||||
struct movable
|
BLT_TRACE("TYPE1: {}", some_type1.call_member(&default_type::to_string));
|
||||||
{
|
BLT_TRACE("TYPE2: {}", some_type2.call_member(&default_type::to_string));
|
||||||
movable() = default;
|
BLT_TRACE("TYPE3: {}", some_type3.call_member(&default_type::to_string));
|
||||||
movable(movable&&) = delete;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct movable_nothrow
|
|
||||||
{
|
|
||||||
movable_nothrow() = default;
|
|
||||||
movable_nothrow(movable_nothrow&&) noexcept = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
blt::variant_t<no_default> no_default_variant;
|
|
||||||
blt::variant_t<not_copyable> not_copyable_variant;
|
|
||||||
blt::variant_t<copyable> copyable_variant;
|
|
||||||
blt::variant_t<copyable_nothrow> copyable_nothrow_variant;
|
|
||||||
blt::variant_t<not_movable> not_movable_variant;
|
|
||||||
blt::variant_t<movable> movable_variant;
|
|
||||||
blt::variant_t<movable_nothrow> movable_nothrow_variant;
|
|
||||||
|
|
||||||
using namespace blt::gp;
|
using namespace blt::gp;
|
||||||
|
|
||||||
|
@ -144,6 +133,8 @@ bool fitness_function(const tree_t& current_tree, fitness_t& fitness, size_t)
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
test();
|
||||||
|
return 0;
|
||||||
operator_builder<context> builder{};
|
operator_builder<context> builder{};
|
||||||
const auto& operators = builder.build(addf, subf, mulf, pro_divf, op_sinf, op_cosf, op_expf, op_logf, litf, op_xf);
|
const auto& operators = builder.build(addf, subf, mulf, pro_divf, op_sinf, op_cosf, op_expf, op_logf, litf, op_xf);
|
||||||
regression.get_program().set_operations(operators);
|
regression.get_program().set_operations(operators);
|
||||||
|
|
Loading…
Reference in New Issue