remove unnecessary code

This commit is contained in:
BlackMATov
2023-12-29 16:43:55 +07:00
parent 5fd20c8bad
commit fe2c1045e2
9 changed files with 14 additions and 154 deletions

View File

@@ -12,7 +12,6 @@
#include <cassert>
#include <climits>
#include <compare>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
@@ -24,7 +23,6 @@
#include <map>
#include <memory>
#include <mutex>
#include <set>
#include <span>
#include <string>
#include <string_view>
@@ -871,27 +869,6 @@ namespace meta_hpp::detail
}
}
namespace meta_hpp::detail
{
template < typename Key, typename Compare, typename Allocator >
void insert_or_assign( //
std::set<Key, Compare, Allocator>& set,
std::set<Key, Compare, Allocator>& value
) {
set.swap(value);
set.merge(value);
}
template < typename Key, typename Compare, typename Allocator >
void insert_or_assign( //
std::set<Key, Compare, Allocator>& set,
std::set<Key, Compare, Allocator>&& value
) {
set.swap(value);
set.merge(std::move(value));
}
}
namespace meta_hpp::detail
{
template < typename Key, typename Value, typename Compare, typename Allocator >
@@ -1109,32 +1086,6 @@ namespace std
};
}
namespace meta_hpp::detail
{
template < typename SortedContainerL, typename SortedContainerR, typename Compare >
bool is_disjoint(const SortedContainerL& l, const SortedContainerR& r, Compare compare) {
using std::begin;
using std::end;
for ( auto iter_l{begin(l)}, iter_r{begin(r)}; iter_l != end(l) && iter_r != end(r); ) {
if ( compare(*iter_l, *iter_r) ) {
++iter_l;
} else if ( compare(*iter_r, *iter_l) ) {
++iter_r;
} else {
return false;
}
}
return true;
}
template < typename SortedContainerL, typename SortedContainerR >
bool is_disjoint(const SortedContainerL& l, const SortedContainerR& r) {
return is_disjoint(l, r, std::less<>{});
}
}
namespace meta_hpp::detail
{
template < typename T >
@@ -4223,14 +4174,14 @@ namespace meta_hpp::detail
static auto data{std::make_unique<TypeData>(std::forward<Args>(args)...)};
const locker lock;
types_.emplace(any_type{data.get()});
types_.emplace_back(data.get());
return data.get();
}
private:
std::recursive_mutex mutex_;
std::set<any_type, std::less<>> types_;
std::vector<any_type> types_;
};
}

View File

@@ -1,30 +0,0 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <meta.hpp/meta_all.hpp>
#include <doctest/doctest.h>
TEST_CASE("meta/meta_base/is_disjoint") {
namespace meta = meta_hpp;
using meta::detail::is_disjoint;
CHECK(is_disjoint(std::set<int>{}, std::set<int>{}));
CHECK(is_disjoint(std::set<int>{1}, std::set<int>{}));
CHECK(is_disjoint(std::set<int>{}, std::set<int>{1}));
CHECK_FALSE(is_disjoint(std::set<int>{1}, std::set<int>{1}));
CHECK_FALSE(is_disjoint(std::set<int>{1,2}, std::set<int>{1}));
CHECK_FALSE(is_disjoint(std::set<int>{1}, std::set<int>{1,2}));
CHECK_FALSE(is_disjoint(std::set<int>{1,2}, std::set<int>{1,3}));
CHECK_FALSE(is_disjoint(std::set<int>{1,3}, std::set<int>{1,2}));
CHECK(is_disjoint(std::set<int>{1,2}, std::set<int>{3,4}));
CHECK(is_disjoint(std::set<int>{2,3}, std::set<int>{1,4,5}));
CHECK(is_disjoint(std::set<int>{2,4}, std::set<int>{1,3,5}));
}

View File

@@ -17,30 +17,30 @@ TEST_CASE("meta/meta_features/for_each_type") {
namespace meta = meta_hpp;
SUBCASE("any_type") {
std::set<meta_hpp::any_type> all_types;
std::vector<meta_hpp::any_type> all_types;
meta::for_each_type([&all_types](const meta::any_type& type){
all_types.insert(type);
all_types.push_back(type);
});
CHECK_FALSE(all_types.contains(meta::resolve_type<A>()));
CHECK_FALSE(std::find(all_types.begin(), all_types.end(), meta::resolve_type<A>()) != all_types.end());
meta::for_each_type([&all_types](const meta::any_type& type){
all_types.insert(type);
all_types.push_back(type);
});
CHECK(all_types.contains(meta::resolve_type<A>()));
CHECK(std::find(all_types.begin(), all_types.end(), meta::resolve_type<A>()) != all_types.end());
}
SUBCASE("specific_type") {
std::set<meta_hpp::array_type> all_types;
std::vector<meta_hpp::array_type> all_types;
meta::for_each_type<meta::array_type>([&all_types](const meta::array_type& type){
all_types.insert(type);
all_types.push_back(type);
});
CHECK_FALSE(all_types.contains(meta::resolve_type<A[]>()));
CHECK_FALSE(std::find(all_types.begin(), all_types.end(), meta::resolve_type<A[]>()) != all_types.end());
meta::for_each_type<meta::array_type>([&all_types](const meta::array_type& type){
all_types.insert(type);
all_types.push_back(type);
});
CHECK(all_types.contains(meta::resolve_type<A[]>()));
CHECK(std::find(all_types.begin(), all_types.end(), meta::resolve_type<A[]>()) != all_types.end());
}
}

View File

@@ -7,8 +7,6 @@
#include <meta.hpp/meta_all.hpp>
#include <doctest/doctest.h>
#include <sstream>
namespace
{
struct ivec2 {

View File

@@ -17,7 +17,6 @@
#include "meta_base/hashed_string.hpp"
#include "meta_base/insert_or_assign.hpp"
#include "meta_base/intrusive_ptr.hpp"
#include "meta_base/is_disjoint.hpp"
#include "meta_base/is_in_place_type.hpp"
#include "meta_base/memory_buffer.hpp"
#include "meta_base/noncopyable.hpp"

View File

@@ -17,7 +17,6 @@
#include <array>
#include <atomic>
#include <compare>
#include <concepts>
#include <deque>
#include <exception>
#include <functional>
@@ -25,7 +24,6 @@
#include <map>
#include <memory>
#include <mutex>
#include <set>
#include <span>
#include <string>
#include <string_view>

View File

@@ -38,27 +38,6 @@ namespace meta_hpp::detail
}
}
namespace meta_hpp::detail
{
template < typename Key, typename Compare, typename Allocator >
void insert_or_assign( //
std::set<Key, Compare, Allocator>& set,
std::set<Key, Compare, Allocator>& value
) {
set.swap(value);
set.merge(value);
}
template < typename Key, typename Compare, typename Allocator >
void insert_or_assign( //
std::set<Key, Compare, Allocator>& set,
std::set<Key, Compare, Allocator>&& value
) {
set.swap(value);
set.merge(std::move(value));
}
}
namespace meta_hpp::detail
{
template < typename Key, typename Value, typename Compare, typename Allocator >

View File

@@ -1,35 +0,0 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
#include "base.hpp"
namespace meta_hpp::detail
{
template < typename SortedContainerL, typename SortedContainerR, typename Compare >
bool is_disjoint(const SortedContainerL& l, const SortedContainerR& r, Compare compare) {
using std::begin;
using std::end;
for ( auto iter_l{begin(l)}, iter_r{begin(r)}; iter_l != end(l) && iter_r != end(r); ) {
if ( compare(*iter_l, *iter_r) ) {
++iter_l;
} else if ( compare(*iter_r, *iter_l) ) {
++iter_r;
} else {
return false;
}
}
return true;
}
template < typename SortedContainerL, typename SortedContainerR >
bool is_disjoint(const SortedContainerL& l, const SortedContainerR& r) {
return is_disjoint(l, r, std::less<>{});
}
}

View File

@@ -164,13 +164,13 @@ namespace meta_hpp::detail
static auto data{std::make_unique<TypeData>(std::forward<Args>(args)...)};
const locker lock;
types_.emplace(any_type{data.get()});
types_.emplace_back(data.get());
return data.get();
}
private:
std::recursive_mutex mutex_;
std::set<any_type, std::less<>> types_;
std::vector<any_type> types_;
};
}