Browse Source

DEV: small twists

concepts
Christos Choutouridis 4 years ago
parent
commit
fa431d5be7
8 changed files with 22 additions and 19 deletions
  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 View File

@@ -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 View File

@@ -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 View File

@@ -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 View File

@@ -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 View File

@@ -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 View File

@@ -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 View File

@@ -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 View File

@@ -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…
Cancel
Save