Skip to content

Commit

Permalink
provide an explicit error message when trying to construct an abstrac…
Browse files Browse the repository at this point in the history
…t class
  • Loading branch information
anderslanglands committed Aug 27, 2024
1 parent 452e94e commit dd267dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.15)
project(babble VERSION 0.7.0 LANGUAGES C CXX)
project(babble VERSION 0.8.0 LANGUAGES C CXX)

find_package(Clang REQUIRED)
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)"
Expand Down
2 changes: 2 additions & 0 deletions bbl/include/babble
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public:

template <typename... Args> struct Ctor {
template <typename... CtorArgs> Ctor(CtorArgs...) {
static_assert(std::is_abstract_v<C> == false, "cannot construct an abstract class");
// Make sure length of provided name args matches the length of the type
// args
if constexpr (sizeof...(CtorArgs) > 0) {
Expand All @@ -104,6 +105,7 @@ public:
/// Bind a constructor
template <typename T = C, typename... Args>
Class ctor(Ctor<Args...> ctor, const char* rename = "") {
static_assert(std::is_abstract_v<C> == false, "cannot construct an abstract class");
static_assert(std::is_constructible<T, Args...>::value,
"can not construct class with these arguments");

Expand Down

0 comments on commit dd267dd

Please sign in to comment.