mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-15 03:45:30 +07:00
examples cleanup
This commit is contained in:
@@ -16,6 +16,7 @@ target_compile_options(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-exit-time-destructors
|
||||
-Wno-padded
|
||||
-Wno-unneeded-internal-declaration
|
||||
-Wno-unused-macros
|
||||
-Wno-unused-member-function
|
||||
-Wno-weak-vtables
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include "../meta_manuals.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
class shape {
|
||||
@@ -60,11 +58,17 @@ TEST_CASE("meta/meta_manuals/class/type") {
|
||||
const meta::class_type rectangle_type = meta::resolve_type<rectangle>();
|
||||
|
||||
// prints all class methods
|
||||
std::cout << "* rectangle" << std::endl;
|
||||
fmt::print("* rectangle\n");
|
||||
for ( const meta::method& method : rectangle_type.get_methods() ) {
|
||||
std::cout << " + " << method.get_name()
|
||||
<< "/" << method.get_type().get_arity() << std::endl;
|
||||
fmt::print(" + {}/{}\n",
|
||||
method.get_name(),
|
||||
method.get_type().get_arity());
|
||||
}
|
||||
|
||||
// Output:
|
||||
// * rectangle
|
||||
// + get_height/0
|
||||
// + get_width/0
|
||||
}
|
||||
|
||||
TEST_CASE("meta/meta_manuals/class/usage") {
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include "../meta_manuals.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
enum class align {
|
||||
@@ -36,11 +34,18 @@ TEST_CASE("meta/meta_manuals/enum/type") {
|
||||
CHECK(align_type.get_underlying_type() == meta::resolve_type<int>());
|
||||
|
||||
// prints all enumerators
|
||||
std::cout << "* align" << std::endl;
|
||||
fmt::print("* align\n");
|
||||
for ( const meta::evalue& evalue : align_type.get_evalues() ) {
|
||||
std::cout << " - " << evalue.get_name()
|
||||
<< "/" << evalue.get_underlying_value_as<int>() << std::endl;
|
||||
fmt::print(" - {}/{}\n",
|
||||
evalue.get_name(),
|
||||
evalue.get_underlying_value_as<int>());
|
||||
}
|
||||
|
||||
// Output:
|
||||
// * align
|
||||
// - center/2
|
||||
// - left/0
|
||||
// - right/1
|
||||
}
|
||||
|
||||
TEST_CASE("meta/meta_manuals/enum/usage") {
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include "../meta_manuals.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
int add(int a, int b) {
|
||||
@@ -73,9 +71,15 @@ TEST_CASE("meta/meta_manuals/function/usage") {
|
||||
CHECK(sub_function_typed_result == 42);
|
||||
|
||||
// prints all functions in the scope
|
||||
std::cout << "* " << math_scope.get_name() << std::endl;
|
||||
fmt::print("* {}\n", math_scope.get_name());
|
||||
for ( const meta::function& function : math_scope.get_functions() ) {
|
||||
std::cout << " + " << function.get_name()
|
||||
<< "/" << function.get_type().get_arity() << std::endl;
|
||||
fmt::print(" + {}/{}\n",
|
||||
function.get_name(),
|
||||
function.get_type().get_arity());
|
||||
}
|
||||
|
||||
// Output:
|
||||
// * math
|
||||
// + add/2
|
||||
// + sub/2
|
||||
}
|
||||
|
||||
@@ -19,26 +19,22 @@ namespace
|
||||
const ivec2 unit2{1, 1};
|
||||
const ivec3 unit3{1, 1, 1};
|
||||
|
||||
[[maybe_unused]]
|
||||
int dot2(const ivec2& a, const ivec2& b) {
|
||||
return a.x * b.x
|
||||
+ a.y * b.y;
|
||||
}
|
||||
|
||||
[[maybe_unused]]
|
||||
int dot3(const ivec3& a, const ivec3& b) {
|
||||
return a.x * b.x
|
||||
+ a.y * b.y
|
||||
+ a.z * b.z;
|
||||
}
|
||||
|
||||
[[maybe_unused]]
|
||||
bool operator==(const ivec2& a, const ivec2& b) {
|
||||
return a.x == b.x
|
||||
&& a.y == b.y;
|
||||
}
|
||||
|
||||
[[maybe_unused]]
|
||||
bool operator==(const ivec3& a, const ivec3& b) {
|
||||
return a.x == b.x
|
||||
&& a.y == b.y
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include "../meta_manuals.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
const double pi_v{3.1415926536};
|
||||
@@ -42,9 +40,15 @@ TEST_CASE("meta/meta_manuals/variable/usage") {
|
||||
CHECK_THROWS(pi_variable.set(6.0));
|
||||
|
||||
// prints all variables in the scope
|
||||
std::cout << "* " << constants_scope.get_name() << std::endl;
|
||||
fmt::print("* {}\n", constants_scope.get_name());
|
||||
for ( const meta::variable& variable : constants_scope.get_variables() ) {
|
||||
std::cout << " - " << variable.get_name()
|
||||
<< ":" << variable.get_as<double>() << std::endl;
|
||||
fmt::print(" - {} : {}\n",
|
||||
variable.get_name(),
|
||||
variable.get_as<double>());
|
||||
}
|
||||
|
||||
// Output:
|
||||
// * constants
|
||||
// - pi_v : 3.1415926536
|
||||
// - sqrt2_v : 1.4142135624
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <iosfwd>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
Reference in New Issue
Block a user