Selaa lähdekoodia

DEV: small twists

concepts
Christos Choutouridis 4 vuotta sitten
vanhempi
commit
fa431d5be7
8 muutettua tiedostoa jossa 22 lisäystä ja 19 poistoa
  1. +2
    -2
      include/utl/concepts/stl.h
  2. +3
    -3
      include/utl/dev/dev_iterators.h
  3. +3
    -3
      include/utl/meta/basic.h
  4. +1
    -1
      include/utl/meta/detection.h
  5. +3
    -3
      include/utl/meta/invoke.h
  6. +2
    -2
      include/utl/meta/sfinae.h
  7. +3
    -0
      include/utl/meta/typelist.h
  8. +5
    -5
      test/tests/TmetaBasic.cpp

+ 2
- 2
include/utl/concepts/stl.h Näytä tiedosto

@@ -34,7 +34,7 @@ namespace utl {
template <typename _T1, typename _T2, typename _Ret =_T1>
using use_if_same_t = meta::eval<
meta::enable_if<
meta::same_<_T1, _T2>::value, _Ret
meta::same<_T1, _T2>::value, _Ret
>
>;
@@ -43,7 +43,7 @@ namespace utl {
* Same
*/
template <class T, class U>
_utlConcept Same = meta::same_<T, U>::value;
_utlConcept Same = meta::same<T, U>::value;
// template<class T>
// _utlConcept Decayed = Same<T, std::decay_t<T>>;


+ 3
- 3
include/utl/dev/dev_iterators.h Näytä tiedosto

@@ -398,7 +398,7 @@ namespace utl {
typename T::difference_type;
typename T::pointer;
typename T::reference;
requires same_<
requires same<
typename T::iterator_category,
std::output_iterator_tag
>::value;
@@ -675,7 +675,7 @@ namespace utl {
typename T::difference_type;
typename T::pointer;
typename T::reference;
requires same_ <
requires same <
typename T::iterator_category,
std::input_iterator_tag
>::value;
@@ -960,7 +960,7 @@ namespace utl {
typename T::difference_type;
typename T::pointer;
typename T::reference;
requires same_<
requires same<
typename T::iterator_category,
std::input_iterator_tag
>::value;


+ 3
- 3
include/utl/meta/basic.h Näytä tiedosto

@@ -292,13 +292,13 @@ namespace meta{
//! \name same
//! @{
template<typename T1, typename T2>
struct same_ : false_ { };
struct same : false_ { };
template<typename Tp>
struct same_ <Tp, Tp> : true_ { };
struct same <Tp, Tp> : true_ { };
template<typename T1, typename T2>
using not_same_ = not_<eval<same_<T1, T2>>>;
using not_same = not_<eval<same<T1, T2>>>;
//! @}
//! @}


+ 1
- 1
include/utl/meta/detection.h Näytä tiedosto

@@ -179,7 +179,7 @@ namespace meta {
template <typename Expected,
template<typename...> class Op, typename... Args >
using is_detected_exact = eval <
same_<Expected, detected_t<Op, Args...>>
same<Expected, detected_t<Op, Args...>>
>;
//! evaluates to true if evaluation of Op<Args...> is \p Expected and to false if not


+ 3
- 3
include/utl/meta/invoke.h Näytä tiedosto

@@ -140,7 +140,7 @@ namespace meta{
static nil_ check (...); //< all other combinations
using type = if_ <
not_same_<
not_same<
nil_,
decltype(check<F>(0))
>, true_, false_
@@ -419,13 +419,13 @@ namespace meta{
template <typename T1>
struct same_as {
template <typename T2>
struct apply : same_<T1, T2> { };
struct apply : same<T1, T2> { };
};
template <typename T1>
struct not_same_as {
template <typename T2>
struct apply : not_same_<T1, T2> { };
struct apply : not_same<T1, T2> { };
};
}}


+ 2
- 2
include/utl/meta/sfinae.h Näytä tiedosto

@@ -54,12 +54,12 @@ namespace meta {
//! If same type resolves to _Ret, else SFINAE
template <typename _T1, typename _T2, typename _Ret =_T1>
using use_if_same_t = enable_if_t<
same_<_T1, _T2>::value, _Ret
same<_T1, _T2>::value, _Ret
>;
//! If not same type resolves to _Ret, else SFINAE
template <typename _T1, typename _T2, typename _Ret =_T1>
using use_if_not_same_t = enable_if_t<
!same_<_T1, _T2>::value, _Ret
!same<_T1, _T2>::value, _Ret
>;
//! If any type (_T1 or _T2) type resolves to _Ret, else to SFINAE
template <typename T1, typename... Ts>


+ 3
- 0
include/utl/meta/typelist.h Näytä tiedosto

@@ -705,6 +705,9 @@ namespace meta {
using seek = seek_if <List, same_as<T>>;
//! @}
template <typename List, typename Pred>
using first_if = front<seek_if<List, Pred>>;
//! \name count_if
//! @{
namespace count_if_impl {


+ 5
- 5
test/tests/TmetaBasic.cpp Näytä tiedosto

@@ -140,9 +140,9 @@ namespace TmetaBasic {
EXPECT_EQ (true, (std::is_same<true_, and_<true_, true_, true_>>()));
EXPECT_EQ (true, (std::is_same<false_, and_<true_, true_, false_>>()));
EXPECT_EQ (true, (same_<Foo, Foo>()));
EXPECT_EQ (false, (same_<Foo, Bar>()));
EXPECT_EQ (true, (not_same_<Foo, Bar>()));
EXPECT_EQ (true, (same<Foo, Foo>()));
EXPECT_EQ (false, (same<Foo, Bar>()));
EXPECT_EQ (true, (not_same<Foo, Bar>()));
}
@@ -218,11 +218,11 @@ namespace TmetaBasic {
/*
* SFINAE
*/
template <typename T, typename =when<same_<T, int>::type::value>>
template <typename T, typename =when<same<T, int>::type::value>>
int check1 (T x) { return x; }
int check1 (...) { return 0; }
template <typename T, typename =enable_if_t<same_<T, int>::type::value, void>>
template <typename T, typename =enable_if_t<same<T, int>::type::value, void>>
int check2 (T x) { return x; }
int check2 (...) { return 0; }


Loading…
Peruuta
Tallenna