Tag: c++20

  • declval()() – what does this mean in the below context?

    declval()() – what does this mean in the below context?

    18 This is from: https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/include/std/type_traits template<typename _Xp, typename _Yp> using __cond_res = decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); … template<typename _Tp1, typename _Tp2> struct __common_reference_impl<_Tp1, _Tp2, 3, void_t<__cond_res<_Tp1, _Tp2>>> { using type = __cond_res<_Tp1, _Tp2>; }; I’m trying to figure out what _Xp(&)() is – is it a function call signature? i.e. a constructor? Doesn’t really…

  • What is the best approach for using std::ranges/std::views with std::expected in C++23?

    What is the best approach for using std::ranges/std::views with std::expected in C++23?

    8 Let me describe a scenario, first we have a function which returns us some sort of data which we can’t be sure about the validity of, i.e. auto random_predicate() -> bool { int v = uniform_dist(e1); // uniform distribution 1 to 100 return (v % 5); } where uniform_dist() is an appropriately seeded uniform…