Skip to content

Commit

Permalink
Drop support for C++14
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadden committed Dec 30, 2020
1 parent 445ebc6 commit 7747abd
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 100 deletions.
17 changes: 1 addition & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,7 @@ else()
set(IS_MSVC false)
endif()

# Decide if we should be using C++14 or C++17.
if(IS_GCC)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
set(CMAKE_CXX_STANDARD 14)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
elseif(IS_CLANG)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
set(CMAKE_CXX_STANDARD 14)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
else()
set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_CXX_STANDARD 17)

# Enable a high level of compiler warnings and treat them as errors.
if(IS_GCC)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ alia - A Library for Interactive Applications
[![GCC Build Status](https://github.com/tmadden/alia/workflows/GCC/badge.svg)](https://github.com/tmadden/alia/actions)
[![Clang Build Status](https://github.com/tmadden/alia/workflows/Clang/badge.svg)](https://github.com/tmadden/alia/actions)
[![codecov](https://codecov.io/gh/tmadden/alia/branch/master/graph/badge.svg)](https://codecov.io/gh/tmadden/alia)
![C++ Support](https://badgen.net/badge/C++/14%2C17/green)
![C++ Support](https://badgen.net/badge/C++/17/green)
[![Stability](https://badgen.net/badge/stability/unstable/yellow)](https://github.com/orangemug/stability-badges#unstable)

</div>
Expand Down
37 changes: 1 addition & 36 deletions src/alia/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,6 @@ struct exception : std::exception
#define ALIA_UNUSED
#endif

// implementation of C++17's void_t that works on C++11 compilers
template<typename... Ts>
struct make_void
{
typedef void type;
};
template<typename... Ts>
using void_t = typename make_void<Ts...>::type;

// implementation of C++17's is_invocable for C++14
template<class F, class... Args>
struct is_invocable
: std::is_constructible<
std::function<void(Args...)>,
std::reference_wrapper<typename std::remove_reference<F>::type>>
{
};

// ALIA_LAMBDIFY(f) produces a lambda that calls f, which is essentially a
// version of f that can be passed as an argument and still allows normal
// overload resolution.
Expand Down Expand Up @@ -141,10 +123,7 @@ class function_view<Return(Args...)> final
};

// uncaught_exception_detector is a utility for detecting whether or not an
// object is being destructed due to an uncaught exception. It uses
// std::uncaught_exceptions() if available and std::uncaught_exception() if
// not.
#if __cplusplus >= 201703L
// object is being destructed due to an uncaught exception.
struct uncaught_exception_detector
{
uncaught_exception_detector()
Expand All @@ -161,20 +140,6 @@ struct uncaught_exception_detector
private:
int base_exception_count_;
};
#else
struct uncaught_exception_detector
{
uncaught_exception_detector()
{
}

bool
detect()
{
return std::uncaught_exception();
}
};
#endif

} // namespace alia

Expand Down
10 changes: 5 additions & 5 deletions src/alia/context/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ copy_context(Context ctx)

namespace detail {

template<class Object, class = void_t<>>
template<class Object, class = std::void_t<>>
struct has_value_id : std::false_type
{
};
template<class Object>
struct has_value_id<
Object,
void_t<decltype(static_cast<id_interface const&>(
std::void_t<decltype(static_cast<id_interface const&>(
std::declval<Object>().value_id()))>> : std::true_type
{
};
Expand All @@ -224,14 +224,14 @@ get_alia_value_id(Object const& object)

namespace detail {

template<class Object, class = void_t<>>
template<class Object, class = std::void_t<>>
struct has_alia_value_id : std::false_type
{
};
template<class Object>
struct has_alia_value_id<
Object,
void_t<decltype(static_cast<id_interface const&>(
std::void_t<decltype(static_cast<id_interface const&>(
get_alia_value_id(std::declval<Object>())))>> : std::true_type
{
};
Expand Down Expand Up @@ -308,7 +308,7 @@ get_content_id(context ctx)
}

// optional_context is basically just std::optional for contexts.
// (alia supports C++14, which is why we don't use std::optional directly.)
// (Its existence may or may not be justified now that alia requires C++17.)
template<class Context>
struct optional_context
{
Expand Down
4 changes: 2 additions & 2 deletions src/alia/flow/conditionals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
namespace alia {

template<class Context, class Function>
std::enable_if_t<is_invocable<Function>::value>
std::enable_if_t<std::is_invocable<Function>::value>
invoke_component_function(Context, Function&& function)
{
std::forward<Function>(function)();
}

template<class Context, class Function>
std::enable_if_t<is_invocable<Function, Context>::value>
std::enable_if_t<std::is_invocable<Function, Context>::value>
invoke_component_function(Context ctx, Function&& function)
{
std::forward<Function>(function)(ctx);
Expand Down
23 changes: 13 additions & 10 deletions src/alia/flow/for_each.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ namespace alia {
// whether or not Container behaves like a map for the purposes of alia
// iteration and indexing. (This is determined by checking whether or not
// Container has both a key_type and a mapped_type member.)
template<class T, class = void_t<>>
template<class T, class = std::void_t<>>
struct is_map_like : std::false_type
{
};
template<class T>
struct is_map_like<T, void_t<typename T::key_type, typename T::mapped_type>>
struct is_map_like<
T,
std::void_t<typename T::key_type, typename T::mapped_type>>
: std::true_type
{
};
Expand All @@ -27,14 +29,14 @@ struct is_map_like<T, void_t<typename T::key_type, typename T::mapped_type>>
// iteration and indexing. (This is determined by checking whether or not
// Container can be subscripted with a size_t. This is sufficient because the
// main purpose is to distinguish vector-like containers from list-like ones.)
template<class Container, class = void_t<>>
template<class Container, class = std::void_t<>>
struct is_vector_like : std::false_type
{
};
template<class Container>
struct is_vector_like<
Container,
void_t<
std::void_t<
typename Container::value_type,
typename Container::size_type,
decltype(std::declval<Container>().at(size_t(0)))>> : std::true_type
Expand All @@ -57,7 +59,7 @@ template<
class Key,
class Value,
std::enable_if_t<
is_invocable<
std::is_invocable<
IterationBody&&,
Context,
naming_context&,
Expand All @@ -82,7 +84,7 @@ template<
class Key,
class Value,
std::enable_if_t<
is_invocable<IterationBody&&, Context, Key&&, Value&&>::value,
std::is_invocable<IterationBody&&, Context, Key&&, Value&&>::value,
int> = 0>
void
invoke_map_iteration_body(
Expand Down Expand Up @@ -138,7 +140,7 @@ template<
class NamedBlockBegin,
class Item,
std::enable_if_t<
is_invocable<
std::is_invocable<
IterationBody&&,
Context,
naming_context&,
Expand All @@ -162,7 +164,7 @@ template<
class NamedBlockBegin,
class Item,
std::enable_if_t<
is_invocable<IterationBody&&, Context, size_t, Item&&>::value,
std::is_invocable<IterationBody&&, Context, size_t, Item&&>::value,
int> = 0>
void
invoke_sequence_iteration_body(
Expand All @@ -183,7 +185,8 @@ template<
class NamedBlockBegin,
class Item,
std::enable_if_t<
is_invocable<IterationBody&&, Context, naming_context&, Item&&>::value,
std::is_invocable<IterationBody&&, Context, naming_context&, Item&&>::
value,
int> = 0>
void
invoke_sequence_iteration_body(
Expand All @@ -202,7 +205,7 @@ template<
class NamedBlockBegin,
class Item,
std::enable_if_t<
is_invocable<IterationBody&&, Context, Item&&>::value,
std::is_invocable<IterationBody&&, Context, Item&&>::value,
int> = 0>
void
invoke_sequence_iteration_body(
Expand Down
4 changes: 2 additions & 2 deletions src/alia/flow/try_catch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ struct lambda_arg_type : call_operator_arg_type<decltype(&Lambda::operator())>
{
};

template<class Clause, class = void_t<>>
template<class Clause, class = std::void_t<>>
struct is_concrete_clause : std::false_type
{
};
template<class Clause>
struct is_concrete_clause<
Clause,
void_t<typename lambda_arg_type<Clause>::type>> : std::true_type
std::void_t<typename lambda_arg_type<Clause>::type>> : std::true_type
{
};

Expand Down
13 changes: 7 additions & 6 deletions src/alia/signals/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,24 +496,25 @@ operator->*(

// has_value_type<T>::value yields a compile-time boolean indicating whether or
// not T has a value_type member (which is the case for standard containers).
template<class T, class = void_t<>>
template<class T, class = std::void_t<>>
struct has_value_type : std::false_type
{
};
template<class T>
struct has_value_type<T, void_t<typename T::value_type>> : std::true_type
struct has_value_type<T, std::void_t<typename T::value_type>> : std::true_type
{
};

// has_mapped_type<T>::value yields a compile-time boolean indicating whether
// or not T has a mapped_type member (which is the case for standard
// associative containers, or at least the ones that aren't sets).
template<class T, class = void_t<>>
template<class T, class = std::void_t<>>
struct has_mapped_type : std::false_type
{
};
template<class T>
struct has_mapped_type<T, void_t<typename T::mapped_type>> : std::true_type
struct has_mapped_type<T, std::void_t<typename T::mapped_type>>
: std::true_type
{
};

Expand Down Expand Up @@ -564,15 +565,15 @@ struct subscript_result_type<
// has_at_indexer<Container, Index>::value yields a compile-time boolean
// indicating whether or not Container has an 'at' member function that takes
// an Index.
template<class Container, class Index, class = void_t<>>
template<class Container, class Index, class = std::void_t<>>
struct has_at_indexer : std::false_type
{
};
template<class Container, class Index>
struct has_at_indexer<
Container,
Index,
void_t<decltype(std::declval<Container const&>().at(
std::void_t<decltype(std::declval<Container const&>().at(
std::declval<Index>()))>> : std::true_type
{
};
Expand Down
16 changes: 0 additions & 16 deletions unit_tests/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@ TEST_CASE("function_view", "[common]")
== 27);
}

TEST_CASE("is_invocable", "[common]")
{
auto f = [](double, int) {};
static_assert(
alia::is_invocable<decltype(f), double, int>::value, "invocable");
static_assert(
!alia::is_invocable<decltype(f), double, std::string>::value,
"type mismatch");
static_assert(
!alia::is_invocable<decltype(f), std::string>::value,
"not enough arguments");
static_assert(
!alia::is_invocable<decltype(f), int, int, std::string>::value,
"too many arguments");
}

struct uncaught_exception_tester
{
uncaught_exception_tester(bool* result) : result(result)
Expand Down
7 changes: 1 addition & 6 deletions unit_tests/signals/adaptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <alia/signals/state.hpp>

#include <move_testing.hpp>
#include <optional>
#include <testing.hpp>

using namespace alia;
Expand Down Expand Up @@ -519,10 +520,6 @@ TEST_CASE("mask/disable_reads", "[signals][adaptors]")
}
}

#if __cplusplus >= 201703L

#include <optional>

TEST_CASE("unwrap a duplex signal", "[signals][adaptors]")
{
{
Expand Down Expand Up @@ -555,8 +552,6 @@ TEST_CASE("unwrap a duplex signal", "[signals][adaptors]")
}
}

#endif

TEST_CASE("signal value movement", "[signals][adaptors]")
{
// Test that copy counting work.
Expand Down

0 comments on commit 7747abd

Please sign in to comment.