Suchergebnisse für Anfrage "overload-resolution"

6 die antwort

Warum passt der Konstruktor der variablen Vorlage besser als der Konstruktor der Kopie?

Der folgende Code wird nicht kompiliert: #include <iostream> #include <utility> struct Foo { Foo() { std::cout << "Foo()" << std::endl; } Foo(int) { std::cout << "Foo(int)" << std::endl; } }; template <typename T> struct Bar { Foo foo; Bar(const ...

4 die antwort

Überladungsregeln für C ++ - Vorlagenfunktionen

Wie sollte der Compiler beim Überladen einer Vorlagenfunktion auswählen, welche Version der Funktion aufgerufen werden soll, wenn er die Option hat, entweder: ufen Sie eine Vorlagenversion der Funktion auf (z. B.func<T>(foo)).Ruft ...

2 die antwort

Warum schlägt die Scala-Typinferenz hier fehl?

Ich habediese Klass [http://jamesgolick.com/2010/2/8/monkey-patching-single-responsibility-principle-and-scala-implicits.html] in Scala: object Util { class Tapper[A](tapMe: A) { def tap(f: A => Unit): A = { f(tapMe) tapMe } def tap(fs: (A => ...

TOP-Veröffentlichungen

4 die antwort

Überlastungsauflösung: Zuordnung von leeren Klammern

Ich habe Code geschriebenS s; ...s = {};, erwartend, dass es dasselbe wie @ endS s = {};. Das tat es jedoch nicht. Das folgende Beispiel reproduziert das Problem: #include <iostream> struct S { S(): a(5) { } S(int t): a(t) {} S &operator=(int t) ...

2 die antwort

Priorität der Listeninitialisierung von Objekt des gleichen Typs

#include <iostream> #include <initializer_list> using namespace std; struct CL { CL(){} CL (std::initializer_list<CL>){cout<<1;} CL (const CL&){cout<<2;} }; int main() { CL cl1; CL cl2 {cl1}; //prints 21 }Hier ist CL struct mit Copy-Konstruktor ...

4 die antwort

Bestimmen, welche Überlastung ausgewählt wurde

Nehmen wir an, ich habe eine willkürlich komplizierte überladene Funktion: template <class T> void foo(T&& ); template <class T> void foo(T* ); void foo(int );Ich möchte für einen bestimmten Ausdruck wissen,welch foo() wird gerufen. Zum ...

4 die antwort

SFINAE passiert nicht mit std :: basic_type

Below SFINAE-Code mit verschiedenen Vorlagen lässt sich mit clang 3.7.1, C ++ 14 gut kompilieren: #include <array> #include <iostream> #include <vector> #include <cstdint> enum class Bar : uint8_t { ay, bee, see }; struct S { static void foo() ...

8 die antwort

Wie wird "std :: cout << std :: endl;" kompiliert?

Die meistenIO Stream-Manipulatoren [http://en.cppreference.com/w/cpp/io/manip] sind reguläre Funktionen mit folgender Signatur: std::ios_base& func( std::ios_base& str );Allerdings einige Manipulatoren (einschließlich der am häufigsten ...

2 die antwort

Wie funktioniert die Ableitung von Vorlagenargumenten, wenn eine überladene Funktion als Argument beteiligt ist?

Dies ist das anspruchsvollere Frage erwähnt inWie funktioniert die Überladungsauflösung, wenn ein Argument eine überladene Funktion ...