Skip to content

Commit

Permalink
Remove trigraphs.
Browse files Browse the repository at this point in the history
  • Loading branch information
edouarda committed Nov 9, 2016
2 parents 25cb2d9 + 3df8928 commit 746659e
Show file tree
Hide file tree
Showing 9 changed files with 1,763 additions and 1,551 deletions.
113 changes: 60 additions & 53 deletions brigand/algorithms/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,71 +7,78 @@ Distributed under the Boost Software License, Version 1.0.
#pragma once

#include <brigand/algorithms/detail/non_null.hpp>
#include <brigand/functions/lambda/apply.hpp>
#include <brigand/config.hpp>
#include <type_traits>
#include <brigand/functions/lambda/apply.hpp>
#include <initializer_list>
#include <type_traits>

namespace brigand
{
#if defined(BRIGAND_COMP_MSVC_2013) || defined(BRIGAND_COMP_CUDA) || defined(BRIGAND_COMP_INTEL)
namespace detail
{
template <bool...> struct bools_ {};
template< typename Sequence, typename Predicate, typename... Ts> struct all_impl;
namespace detail
{
template <bool...>
struct bools_
{
};
template <typename Sequence, typename Predicate, typename... Ts>
struct all_impl;

template< template<class...> class Sequence, typename Predicate, typename... Ts>
struct all_impl<Sequence<Ts...>, Predicate>
: std::is_same< bools_<true, ::brigand::apply<Predicate, Ts>::value...>
, bools_<::brigand::apply<Predicate, Ts>::value..., true>
>
{};
}
template <template <class...> class Sequence, typename Predicate, typename... Ts>
struct all_impl<Sequence<Ts...>, Predicate>
: std::is_same<bools_<true, ::brigand::apply<Predicate, Ts>::value...>,
bools_<::brigand::apply<Predicate, Ts>::value..., true>>
{
};
}
#else
namespace detail
{
struct all_same
{
const bool value = false;
constexpr all_same(...) {}
template <typename T>
constexpr all_same(std::initializer_list<T *>) : value{ true }
{
}
};
namespace detail
{
struct all_same
{
const bool value = false;
constexpr all_same(...) {}
template <typename T>
constexpr all_same(std::initializer_list<T *>) : value{true}
{
}
};

template <typename Sequence, typename Predicate>
struct all_impl : bool_<true>{};
template <typename Sequence, typename Predicate>
struct all_impl : bool_<true>
{
};

template <template <class...> class Sequence, typename Predicate, typename T, typename... Ts>
struct all_impl<Sequence<T,Ts...>, Predicate>
{
static constexpr all_same tester{ static_cast<::brigand::apply<Predicate, T> *>(nullptr),
static_cast<::brigand::apply<Predicate, Ts> *>(nullptr)... };
using type = bool_<(::brigand::apply<Predicate, T>::value != 0 && tester.value)>;
};
template <template <class...> class Sequence, typename Predicate, typename T, typename... Ts>
struct all_impl<Sequence<T, Ts...>, Predicate>
{
static constexpr all_same tester{
static_cast<::brigand::apply<Predicate, T> *>(nullptr),
static_cast<::brigand::apply<Predicate, Ts> *>(nullptr)...};
using type = bool_<(::brigand::apply<Predicate, T>::value != 0 && tester.value)>;
};

template <template <class...> class Sequence, template <typename...> class F, typename T,
typename... Ts>
struct all_impl<Sequence<T, Ts...>, bind<F, _1>>
{
static constexpr all_same tester{ static_cast<F<T> *>(nullptr),
static_cast<F<Ts> *>(nullptr)... };
using type = bool_<(F<T>::value != 0 && tester.value)>;
};
template <template <class...> class Sequence, template <typename...> class F, typename T,
typename... Ts>
struct all_impl<Sequence<T, Ts...>, bind<F, _1>>
{
static constexpr all_same tester{static_cast<F<T> *>(nullptr),
static_cast<F<Ts> *>(nullptr)...};
using type = bool_<(F<T>::value != 0 && tester.value)>;
};

template <template <class...> class Sequence, template <typename...> class F, typename T,
typename... Ts>
struct all_impl<Sequence<T, Ts...>, F<_1>>
{
static constexpr all_same tester{ static_cast<typename F<T>::type *>(nullptr),
static_cast<typename F<Ts>::type *>(nullptr)... };
using type = bool_<(F<T>::type::value != 0 && tester.value)>;
};
}
template <template <class...> class Sequence, template <typename...> class F, typename T,
typename... Ts>
struct all_impl<Sequence<T, Ts...>, F<_1>>
{
static constexpr all_same tester{static_cast<typename F<T>::type *>(nullptr),
static_cast<typename F<Ts>::type *>(nullptr)...};
using type = bool_<(F<T>::type::value != 0 && tester.value)>;
};
}
#endif

// Is a predicate true for every type ?
template <typename Sequence, typename Predicate = detail::non_null>
using all = typename detail::all_impl<Sequence, Predicate>::type;
// Is a predicate true for every type ?
template <typename Sequence, typename Predicate = detail::non_null>
using all = typename detail::all_impl<Sequence, Predicate>::type;
}
63 changes: 32 additions & 31 deletions brigand/algorithms/count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
=================================================================================================**/
#pragma once
#include <brigand/config.hpp>
#include <brigand/functions/lambda.hpp>
#include <brigand/types/integer.hpp>
#include <brigand/config.hpp>
#include <type_traits>

namespace brigand
{
namespace detail
{
constexpr std::size_t count_bools(bool const * const begin, bool const * const end,
std::size_t n)
{
return begin == end ? n : detail::count_bools(begin + 1, end, n + *begin);
}
constexpr std::size_t count_bools(bool const * const begin, bool const * const end,
std::size_t n)
{
return begin == end ? n : detail::count_bools(begin + 1, end, n + *begin);
}

template <bool... Bs>
struct template_count_bools
Expand Down Expand Up @@ -53,45 +53,46 @@ namespace lazy
using type = ::brigand::size_t<0>;
};

#if defined(BRIGAND_COMP_GCC) || defined(BRIGAND_COMP_CLANG) //not MSVC
#if defined(BRIGAND_COMP_GCC) || defined(BRIGAND_COMP_CLANG) // not MSVC

template <template <typename...> class S, template <typename...> class F>
struct count_if<S<>, bind<F, _1>>
{
using type = ::brigand::size_t<0>;
};
template <template <typename...> class S, template <typename...> class F>
struct count_if<S<>, bind<F, _1>>
{
using type = ::brigand::size_t<0>;
};

template <template <typename...> class S, template <typename...> class F>
struct count_if<S<>, F<_1>>
{
using type = ::brigand::size_t<0>;
};
template <template <typename...> class S, template <typename...> class F>
struct count_if<S<>, F<_1>>
{
using type = ::brigand::size_t<0>;
};

template <template<typename...> class S, typename... Ts, typename Pred>
struct count_if<S<Ts...>, Pred>
{
static constexpr bool s_v[] = { ::brigand::apply<Pred, Ts>::type::value... };
using type = brigand::size_t<::brigand::detail::count_bools(s_v, s_v + sizeof...(Ts), 0u)>;
};
template <template <typename...> class S, typename... Ts, typename Pred>
struct count_if<S<Ts...>, Pred>
{
static constexpr bool s_v[] = {::brigand::apply<Pred, Ts>::type::value...};
using type = brigand::size_t<::brigand::detail::count_bools(s_v, s_v + sizeof...(Ts), 0u)>;
};

template <template <typename...> class S, typename... Ts, template <typename...> class F>
struct count_if<S<Ts...>, bind<F, _1>>
{
static constexpr bool s_v[] = { F<Ts>::value... };
using type = brigand::size_t<::brigand::detail::count_bools(s_v, s_v + sizeof...(Ts), 0u)>;
static constexpr bool s_v[] = {F<Ts>::value...};
using type = brigand::size_t<::brigand::detail::count_bools(s_v, s_v + sizeof...(Ts), 0u)>;
};

template <template <typename...> class S, typename... Ts, template <typename...> class F>
struct count_if<S<Ts...>, F<_1>>
{
static constexpr bool s_v[] = { F<Ts>::type::value... };
using type = brigand::size_t<::brigand::detail::count_bools(s_v, s_v + sizeof...(Ts), 0u)>;
static constexpr bool s_v[] = {F<Ts>::type::value...};
using type = brigand::size_t<::brigand::detail::count_bools(s_v, s_v + sizeof...(Ts), 0u)>;
};
#else
template <template <typename...> class S, typename... Ts, typename Pred>
struct count_if<S<Ts...>, Pred> : ::brigand::detail::template_count_bools<::brigand::apply<Pred, Ts>::value...>
{
};
template <template <typename...> class S, typename... Ts, typename Pred>
struct count_if<S<Ts...>, Pred>
: ::brigand::detail::template_count_bools<::brigand::apply<Pred, Ts>::value...>
{
};

#endif
}
Expand Down
1 change: 0 additions & 1 deletion brigand/algorithms/find.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <brigand/sequences/list.hpp>
#include <brigand/sequences/size.hpp>
#include <brigand/types/bool.hpp>
#include <brigand/types/bool.hpp>

namespace brigand
{
Expand Down
106 changes: 55 additions & 51 deletions brigand/algorithms/merge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,83 +15,87 @@

namespace brigand
{
namespace detail
{
template<class L, class Seq1, class Seq2, class Comp>
namespace detail
{
template <class L, class Seq1, class Seq2, class Comp>
struct merge_impl;

template<bool, class L, class Seq1, class Seq2, class Comp>
template <bool, class L, class Seq1, class Seq2, class Comp>
struct merge_insert;

template<class... R, class T0, class T1, class... Ts, class U, class... Us, class Comp>
struct merge_insert<true, list<R...>, list<T0,T1,Ts...>, list<U,Us...>, Comp>
: merge_insert<::brigand::apply<Comp,T1,U>::value, list<R...,T0>, list<T1,Ts...>, list<U,Us...>, Comp>
{};
template <class... R, class T0, class T1, class... Ts, class U, class... Us, class Comp>
struct merge_insert<true, list<R...>, list<T0, T1, Ts...>, list<U, Us...>, Comp>
: merge_insert<::brigand::apply<Comp, T1, U>::value, list<R..., T0>, list<T1, Ts...>,
list<U, Us...>, Comp>
{
};

template<class... R, class T, class U, class... Us, class Comp>
struct merge_insert<true, list<R...>, list<T>, list<U,Us...>, Comp>
template <class... R, class T, class U, class... Us, class Comp>
struct merge_insert<true, list<R...>, list<T>, list<U, Us...>, Comp>
{
using list = ::brigand::list<R...,T>;
using left = ::brigand::list<>;
using right = ::brigand::list<U,Us...>;
using list = ::brigand::list<R..., T>;
using left = ::brigand::list<>;
using right = ::brigand::list<U, Us...>;
};

template<class... R, class T, class... Ts, class U0, class U1, class... Us, class Comp>
struct merge_insert<false, list<R...>, list<T,Ts...>, list<U0,U1,Us...>, Comp>
: merge_insert<::brigand::apply<Comp,T,U1>::value, list<R...,U0>, list<T,Ts...>, list<U1,Us...>, Comp>
{};
template <class... R, class T, class... Ts, class U0, class U1, class... Us, class Comp>
struct merge_insert<false, list<R...>, list<T, Ts...>, list<U0, U1, Us...>, Comp>
: merge_insert<::brigand::apply<Comp, T, U1>::value, list<R..., U0>, list<T, Ts...>,
list<U1, Us...>, Comp>
{
};

template<class... R, class T, class... Ts, class U, class Comp>
struct merge_insert<false, list<R...>, list<T,Ts...>, list<U>, Comp>
template <class... R, class T, class... Ts, class U, class Comp>
struct merge_insert<false, list<R...>, list<T, Ts...>, list<U>, Comp>
{
using list = ::brigand::list<R...,U>;
using left = ::brigand::list<T,Ts...>;
using right = ::brigand::list<>;
using list = ::brigand::list<R..., U>;
using left = ::brigand::list<T, Ts...>;
using right = ::brigand::list<>;
};

template<
class... R,
class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class... Ts,
class U0, class U1, class U2, class U3, class U4, class U5, class U6, class U7, class U8, class U9, class... Us, class Comp>
struct merge_impl<list<R...>, list<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,Ts...>, list<U0,U1,U2,U3,U4,U5,U6,U7,U8,U9,Us...>, Comp>
template <class... R, class T0, class T1, class T2, class T3, class T4, class T5, class T6,
class T7, class T8, class T9, class... Ts, class U0, class U1, class U2, class U3,
class U4, class U5, class U6, class U7, class U8, class U9, class... Us, class Comp>
struct merge_impl<list<R...>, list<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, Ts...>,
list<U0, U1, U2, U3, U4, U5, U6, U7, U8, U9, Us...>, Comp>
{
using sub = merge_insert<::brigand::apply<Comp,T0,U0>::value, list<>, list<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>, list<U0,U1,U2,U3,U4,U5,U6,U7,U8,U9>, Comp>;
using type = typename merge_impl<
append<list<R...>, typename sub::list>,
append<typename sub::left, list<Ts...>>,
append<typename sub::right, list<Us...>>,
Comp
>::type;
using sub = merge_insert<::brigand::apply<Comp, T0, U0>::value, list<>,
list<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>,
list<U0, U1, U2, U3, U4, U5, U6, U7, U8, U9>, Comp>;
using type = typename merge_impl<append<list<R...>, typename sub::list>,
append<typename sub::left, list<Ts...>>,
append<typename sub::right, list<Us...>>, Comp>::type;
};

template<class... R, class T, class... Ts, class U, class... Us, class Comp>
struct merge_impl<list<R...>, list<T,Ts...>, list<U,Us...>, Comp>
: std::conditional<
::brigand::apply<Comp,T,U>::value,
merge_impl<list<R...,T>, list<Ts...>, list<U,Us...>, Comp>,
merge_impl<list<R...,U>, list<T,Ts...>, list<Us...>, Comp>
>::type
{};
template <class... R, class T, class... Ts, class U, class... Us, class Comp>
struct merge_impl<list<R...>, list<T, Ts...>, list<U, Us...>, Comp>
: std::conditional<::brigand::apply<Comp, T, U>::value,
merge_impl<list<R..., T>, list<Ts...>, list<U, Us...>, Comp>,
merge_impl<list<R..., U>, list<T, Ts...>, list<Us...>, Comp>>::type
{
};

template<class... R, class... Ts, class Comp>
template <class... R, class... Ts, class Comp>
struct merge_impl<list<R...>, list<Ts...>, list<>, Comp>
{
using type = list<R..., Ts...>;
using type = list<R..., Ts...>;
};

template<class... R, class... Us, class Comp>
template <class... R, class... Us, class Comp>
struct merge_impl<list<R...>, list<>, list<Us...>, Comp>
{
using type = list<R..., Us...>;
using type = list<R..., Us...>;
};

template<class... R, class Comp>
template <class... R, class Comp>
struct merge_impl<list<R...>, list<>, list<>, Comp>
{
using type = list<R...>;
using type = list<R...>;
};
}
}

template<class Seq1, class Seq2, class Comp = less<_1,_2>>
using merge = append<clear<Seq1>, typename detail::merge_impl<list<>, wrap<Seq1, list>, wrap<Seq2, list>, Comp>::type>;
template <class Seq1, class Seq2, class Comp = less<_1, _2>>
using merge =
append<clear<Seq1>,
typename detail::merge_impl<list<>, wrap<Seq1, list>, wrap<Seq2, list>, Comp>::type>;
}
Loading

0 comments on commit 746659e

Please sign in to comment.