Skip to content

Commit

Permalink
use UTemplate's is_list_initializable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubpa committed May 21, 2020
1 parent 5035784 commit c119d1a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
21 changes: 11 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(UECS VERSION 0.9.1)
project(UECS VERSION 0.9.2)
message(STATUS "[Project] ${PROJECT_NAME}")

include(FetchContent)
message(STATUS "find package: UCMake 0.5.3")
find_package(UCMake 0.5.3 QUIET)
set(UCMake_VERSION 0.5.4)
message(STATUS "find package: UCMake ${UCMake_VERSION}")
find_package(UCMake ${UCMake_VERSION} QUIET)
if(NOT UCMake_FOUND)
message(STATUS "UCMake 0.5.3 not found")
message(STATUS "UCMake ${UCMake_VERSION} not found")
set(_address "https://github.com/Ubpa/UCMake")
message(STATUS "fetch: ${_address} with tag 0.5.3")
message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}")
FetchContent_Declare(
UCMake
GIT_REPOSITORY ${_address}
GIT_TAG "0.5.3"
UCMake
GIT_REPOSITORY ${_address}
GIT_TAG ${UCMake_VERSION}
)
FetchContent_MakeAvailable(UCMake)
message(STATUS "UCMake 0.5.3 build done")
message(STATUS "UCMake ${UCMake_VERSION} build done")
endif()

Ubpa_InitProject()

Ubpa_AddDep(UContainer 0.0.4)
Ubpa_AddDep(UTemplate 0.4.2)
Ubpa_AddDep(UTemplate 0.4.4)

Ubpa_AddSubDirsRec(include)
Ubpa_AddSubDirsRec(src)
Expand Down
16 changes: 3 additions & 13 deletions include/UECS/detail/EntityMngr.inl
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@

#include <UTemplate/Typelist.h>
#include <UTemplate/Func.h>
#include <UTemplate/Concept.h>

namespace Ubpa::detail::EntityMngr_ {
template<typename Cmpt, typename... Ts>
Concept(IsAggregatableHelper, Cmpt{ std::declval<Ts>()... });
template<typename Cmpt, typename... Ts>
struct IsAggregatable : IValue<bool, std::is_aggregate_v<Cmpt> && Require<IsAggregatableHelper, Cmpt, Ts...>> {};
template<typename Cmpt, typename... Ts>
static constexpr bool IsAggregatable_v = IsAggregatable<Cmpt, Ts...>::value;
}

namespace Ubpa {
template<typename... Cmpts>
Expand Down Expand Up @@ -125,7 +115,7 @@ namespace Ubpa {
template<typename... Cmpts>
std::tuple<Cmpts*...> EntityMngr::Attach(Entity e) {
static_assert((std::is_constructible_v<Cmpts> &&...),
"EntityMngr::Attach: <Cmpts> isn't constructible");
"EntityMngr::Attach: <Cmpts> isn't default constructable");
if (!Exist(e)) throw std::invalid_argument("Entity is invalid");

using CmptList = TypeList<Cmpts...>;
Expand Down Expand Up @@ -169,8 +159,8 @@ namespace Ubpa {
template<typename Cmpt, typename... Args>
Cmpt* EntityMngr::Emplace(Entity e, Args&&... args) {
static_assert(std::is_constructible_v<Cmpt, Args...>
|| detail::EntityMngr_::IsAggregatable_v<Cmpt, Args...>,
"EntityMngr::Emplace: <Cmpt> isn't constructible/aggregatable with <Args...>");
|| is_list_initializable_v<Cmpt, Args...>,
"EntityMngr::Emplace: <Cmpt> isn't constructible/list_initializable with Args...");
if (!Exist(e)) throw std::invalid_argument("EntityMngr::Emplace: Entity is invalid");

bool needAttach = entityTable[e.Idx()].archetype->GetCmptTypeSet().IsNotContain<Cmpt>();
Expand Down
3 changes: 2 additions & 1 deletion include/UECS/detail/_deps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Ubpa_DownloadZip(
https://cdn.jsdelivr.net/gh/Ubpa/UData@master/UECS/include/_deps/taskflow.zip
taskflow.zip
SHA256 2B02E44B97BB63568E8C06FAF0ABE71C32E607AE18DA42992C84E000F81BDD9C)
SHA256 2B02E44B97BB63568E8C06FAF0ABE71C32E607AE18DA42992C84E000F81BDD9C
)

0 comments on commit c119d1a

Please sign in to comment.