Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.DS_Store
/build*/

include/iris/alloy/detail/preprocessed/tuple_impl.hpp
30 changes: 26 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,42 @@ endif()
# -----------------------------------------------------------------
# Configure Iris main target

option(IRIS_CI "Enables intensive testing for CI" OFF)
if(IRIS_CI)
target_compile_definitions(iris INTERFACE IRIS_CI=1)
endif()

file(
GLOB_RECURSE IRIS_HEADERS
${PROJECT_SOURCE_DIR}/include/iris/*.hpp
${PROJECT_SOURCE_DIR}/include/iris/*.ipp
)

if(MSVC)
add_custom_command(
OUTPUT ${PROJECT_SOURCE_DIR}/include/iris/alloy/detail/preprocessed/tuple_impl.hpp
COMMAND ${PROJECT_SOURCE_DIR}/scripts/generate_tuple_members.bat
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS ${PROJECT_SOURCE_DIR}/include/iris/alloy/detail/tuple_impl.hpp
VERBATIM
)
else()
add_custom_command(
OUTPUT ${PROJECT_SOURCE_DIR}/include/iris/alloy/detail/preprocessed/tuple_impl.hpp
COMMAND ${PROJECT_SOURCE_DIR}/scripts/generate_tuple_members.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS ${PROJECT_SOURCE_DIR}/include/iris/alloy/detail/tuple_impl.hpp
VERBATIM
)
endif()

list(APPEND IRIS_HEADERS ${PROJECT_SOURCE_DIR}/include/iris/alloy/detail/preprocessed/tuple_impl.hpp)
list(REMOVE_DUPLICATES IRIS_HEADERS)

target_sources(iris PRIVATE FILE_SET HEADERS TYPE HEADERS FILES ${IRIS_HEADERS})
source_group(TREE ${PROJECT_SOURCE_DIR}/include/iris PREFIX iris FILES ${IRIS_HEADERS})
target_include_directories(iris INTERFACE ${PROJECT_SOURCE_DIR}/include)

option(IRIS_CI "Enables intensive testing for CI" OFF)
if(IRIS_CI)
target_compile_definitions(iris INTERFACE IRIS_CI=1)
endif()

# -----------------------------------------------------------------
# Test
Expand Down
35 changes: 35 additions & 0 deletions include/iris/alloy/adapt.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef IRIS_ZZ_ALLOY_ADAPT_HPP
#define IRIS_ZZ_ALLOY_ADAPT_HPP

// SPDX-License-Identifier: MIT

#include <iris/pp/comma.hpp>
#include <iris/pp/seq.hpp>
#include <iris/pp/tuple.hpp>

namespace iris::alloy {

namespace detail {

template<auto... Vs>
struct non_type_list;

} // detail

template<class T>
struct adaptor;

template<auto... Getters>
using make_getters_list = detail::non_type_list<Getters...>;

} // iris::alloy

#define IRIS_ALLOY_ADAPT_STRUCT(class_name, ...) \
template<> \
struct iris::alloy::adaptor<class_name> { \
using getters_list = make_getters_list<IRIS_PP_SEQ_FOR_EACH_WITH_INDEX(IRIS_PP_TUPLE_TO_SEQ((__VA_ARGS__)), IRIS_ALLOY_ADAPT_STRUCT_I, class_name)>; \
};

#define IRIS_ALLOY_ADAPT_STRUCT_I(index, data_member, class_name) IRIS_PP_COMMA_IF(index) & class_name::data_member

#endif
28 changes: 28 additions & 0 deletions include/iris/alloy/adapted/std_pair.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef IRIS_ZZ_ALLOY_ADAPTED_STD_PAIR_HPP
#define IRIS_ZZ_ALLOY_ADAPTED_STD_PAIR_HPP

// SPDX-License-Identifier: MIT

#include <utility>

namespace iris::alloy {

namespace detail {

template<auto... Vs>
struct non_type_list;

} // detail

template<class T>
struct adaptor;

template<class T, class U>
struct adaptor<std::pair<T, U>>
{
using getters_list = detail::non_type_list<&std::pair<T, U>::first, &std::pair<T, U>::second>;
};

} // iris::alloy

#endif
46 changes: 46 additions & 0 deletions include/iris/alloy/adapted/std_tuple.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef IRIS_ZZ_ALLOY_ADAPTED_STD_TUPLE_HPP
#define IRIS_ZZ_ALLOY_ADAPTED_STD_TUPLE_HPP

// SPDX-License-Identifier: MIT

#include <iris/alloy/detail/integer_seq_transform.hpp>

#include <tuple>
#include <utility>

#include <cstddef>

namespace iris::alloy {

template<class T>
struct adaptor;

namespace detail {

template<std::size_t I>
struct call_std_get
{
template<class Tuple>
static constexpr decltype(auto) operator()(Tuple&& t)
{
return std::get<I>(static_cast<Tuple&&>(t));
}
};

template<std::size_t I>
struct make_call_std_get
{
static constexpr auto value = call_std_get<I>{};
};

} // detail

template<class... Ts>
struct adaptor<std::tuple<Ts...>>
{
using getters_list = detail::integer_seq_transform_t<std::make_index_sequence<sizeof...(Ts)>, detail::make_call_std_get>;
};

} // iris::alloy

#endif
40 changes: 40 additions & 0 deletions include/iris/alloy/detail/deduce.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef IRIS_ZZ_ALLOY_DETAIL_DEDUCE_HPP
#define IRIS_ZZ_ALLOY_DETAIL_DEDUCE_HPP

// SPDX-License-Identifier: MIT

#include <type_traits>

namespace iris::alloy::detail {

template<class FromLValue, class FromXValue>
struct deduce
{
static_assert(std::conjunction_v<std::is_reference<FromLValue>, std::is_reference<FromXValue>,
std::is_same<std::remove_reference_t<FromLValue>, std::remove_reference_t<FromXValue>>>);
};

template<class T>
struct deduce<T&, T&>
{
using type = T&;
};

template<class T>
struct deduce<T&, T&&>
{
using type = T;
};

template<class T>
struct deduce<T&&, T&&>
{
using type = T;
};

template<class FromLValue, class FromXValue>
using deduce_t = typename deduce<FromLValue, FromXValue>::type;

} // iris::alloy::detail

#endif
27 changes: 27 additions & 0 deletions include/iris/alloy/detail/integer_seq_transform.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef IRIS_ZZ_ALLOY_DETAIL_INTEGER_SEQ_TRANSFORM_HPP
#define IRIS_ZZ_ALLOY_DETAIL_INTEGER_SEQ_TRANSFORM_HPP

// SPDX-License-Identifier: MIT

#include <utility>

namespace iris::alloy::detail {

template<auto... Vs>
struct non_type_list;

template<class IntegerSeq, template<typename IntegerSeq::value_type> class F>
struct integer_seq_transform;

template<class T, T... Is, template<T> class F>
struct integer_seq_transform<std::integer_sequence<T, Is...>, F>
{
using type = detail::non_type_list<F<Is>::value...>;
};

template<class IntegerSeq, template<typename IntegerSeq::value_type> class F>
using integer_seq_transform_t = typename integer_seq_transform<IntegerSeq, F>::type;

} // iris::alloy::detail

#endif
16 changes: 16 additions & 0 deletions include/iris/alloy/detail/preprocessed/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
AccessModifierOffset: -4
AllowBreakBeforeNoexceptSpecifier: OnlyWithParen
AlwaysBreakTemplateDeclarations : true
ColumnLimit: 160
FixNamespaceComments: false
IndentWidth: 4
NamespaceIndentation: None
PointerAlignment: Left
QualifierAlignment: Right
UseTab: Never
AlignEscapedNewlines: DontAlign
BreakBeforeBraces: Mozilla
SpaceAfterTemplateKeyword: false
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterRequiresInClause: true
2 changes: 2 additions & 0 deletions include/iris/alloy/detail/preprocessed/tuple_impl.hpp.post.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

#endif
17 changes: 17 additions & 0 deletions include/iris/alloy/detail/preprocessed/tuple_impl.hpp.pre.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef IRIS_ZZ_ALLOY_DETAIL_PREPROCESSED_TUPLE_IMPL_HPP
#define IRIS_ZZ_ALLOY_DETAIL_PREPROCESSED_TUPLE_IMPL_HPP

// SPDX-License-Identifier: MIT

#include <iris/config.hpp>

#include <iris/alloy/detail/tuple_comparison.hpp>

#include <iris/alloy/traits.hpp>

#include <iris/type_traits.hpp>

#include <type_traits>

#include <cstddef>

62 changes: 62 additions & 0 deletions include/iris/alloy/detail/tuple_comparison.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#ifndef IRIS_ZZ_ALLOY_DETAIL_TUPLE_COMPARISON_HPP
#define IRIS_ZZ_ALLOY_DETAIL_TUPLE_COMPARISON_HPP

// SPDX-License-Identifier: MIT

#include <iris/requirements.hpp>

#include <concepts>
#include <type_traits>

namespace iris::alloy {

template<class... Ts>
class tuple;

namespace detail {

namespace equality_operator_poison_barrier {

bool operator==(auto, auto) = delete; // poison-pill

template<class T, class U>
concept has_equality_operator = requires(T&& x, U&& y) {
{ static_cast<T&&>(x) == static_cast<U&&>(y) } -> req::boolean_testable;
};

template<class T, class U>
struct is_nothrow_equality_comparable : std::bool_constant<has_equality_operator<T, U> && noexcept(std::declval<T>() == std::declval<U>())> {};

} // equality_operator_poison_barrier

using equality_operator_poison_barrier::has_equality_operator;
using equality_operator_poison_barrier::is_nothrow_equality_comparable;

template<class TTuple, class UTuple>
struct do_tuple_all_elements_have_equality_operator {};

template<class... Ts, class... Us>
struct do_tuple_all_elements_have_equality_operator<tuple<Ts...>, tuple<Us...>>
: std::bool_constant<(has_equality_operator<Ts const&, Us const&> && ...)> {};

template<class TTuple, class UTuple>
inline constexpr bool do_tuple_all_elements_have_equality_operator_v = do_tuple_all_elements_have_equality_operator<TTuple, UTuple>::value;

template<class TTuple, class UTuple>
concept tuple_all_elements_have_equality_operator = do_tuple_all_elements_have_equality_operator_v<TTuple, UTuple>;

template<class TTuple, class UTuple>
struct are_tuple_all_elements_nothrow_equality_comparable {};

template<class... Ts, class... Us>
struct are_tuple_all_elements_nothrow_equality_comparable<tuple<Ts...>, tuple<Us...>>
: std::conjunction<is_nothrow_equality_comparable<Ts const&, Us const&>...> {};

template<class TTuple, class UTuple>
inline constexpr bool are_tuple_all_elements_nothrow_equality_comparable_v = are_tuple_all_elements_nothrow_equality_comparable<TTuple, UTuple>::value;

} // detail

} // iris::alloy

#endif
Loading
Loading