Ich versuche, std :: tuple_size und std :: Get für eine einfache Struktur spezialisiert zu werden, damit ich in einer generischen Funktion std :: anwenden damit verwenden kann. Wenn ich jedoch STD :: anwenden aufrufe, erhalte ich einen Kompilierungsfehler. Interessanterweise, wenn ich die Implementierung von std :: anwenden und std :: __ apply_impl in einen lokalen Namenspace kopiere und diese Version nennt, funktioniert alles einwandfrei.
#include
#include
#include
#include
// Define a simple struct A with different types
struct A {
int i;
double d;
};
// Specialize std::tuple_size and std::get for A
namespace std {
template struct tuple_size : std::integral_constant { }; // 3 members in A
template constexpr decltype(auto) get (const A& a) { if constexpr (N == 0) return (a.i); else if constexpr (N == 1) return (a.d); }
}
// I copied below the code for std::__apply_impl, and std::apply
namespace My {
template
constexpr decltype(auto) apply_impl(Callable&& _Obj, Tuple&& _Tpl,std::index_sequence)
{
using namespace std;
return std::invoke (forward(_Obj), get(forward(_Tpl))...);
}
template
constexpr decltype(auto) apply(Callable&& Obj, Tuple&& Tpl)
{
using namespace std;
return apply_impl(forward(Obj), forward(Tpl), make_index_sequence{});
}
}
int main ()
{
A a {0, 1.5};
// #define COMPILER_ERROR // enabling the define breaks the compiler
#ifdef COMPILER_ERROR
std::apply ([](auto&&... args) {((std::cout
Ich versuche, std :: tuple_size und std :: Get für eine einfache Struktur spezialisiert zu werden, damit ich in einer generischen Funktion std :: anwenden damit verwenden kann. Wenn ich jedoch STD :: anwenden aufrufe, erhalte ich einen Kompilierungsfehler. Interessanterweise, wenn ich die Implementierung von std :: anwenden und std :: __ apply_impl in einen lokalen Namenspace kopiere und diese Version nennt, funktioniert alles einwandfrei.[code]#include #include #include #include
// Define a simple struct A with different types struct A { int i; double d; };
// Specialize std::tuple_size and std::get for A namespace std { template struct tuple_size : std::integral_constant { }; // 3 members in A
template constexpr decltype(auto) get (const A& a) { if constexpr (N == 0) return (a.i); else if constexpr (N == 1) return (a.d); } }
// I copied below the code for std::__apply_impl, and std::apply namespace My { template constexpr decltype(auto) apply_impl(Callable&& _Obj, Tuple&& _Tpl,std::index_sequence) { using namespace std; return std::invoke (forward(_Obj), get(forward(_Tpl))...); }
int main () { A a {0, 1.5}; // #define COMPILER_ERROR // enabling the define breaks the compiler #ifdef COMPILER_ERROR std::apply ([](auto&&... args) {((std::cout
Ich habe eine Winui3 -Anwendung, die drei Grenzen hat und ich möchte reagieren. Wenn die Fenstergröße weniger als 600 beträgt, befinden sich die Grenzen in einer Spalte und größer als die Grenzen in...
Ich habe eine Winui3 -Anwendung, die drei Grenzen hat und ich möchte reagieren. Wenn die Fenstergröße weniger als 600 beträgt, befinden sich die Grenzen in einer Spalte und größer als die Grenzen in...
Ich bin auf meiner Website auf ein Problem gestoßen, bei dem Safari (18.2) und Chrome (132.0.6834.84) völlig unterschiedliche Ergebnisse für ein absolut positioniertes Element liefern.
Auf Chrome...