Explore >> Select a destination


You are here

zig.godbolt.org
| | gcc.godbolt.org
0.1 parsecs away

Travel
| | struct MyPair { int a; int b; }; void CopyPair(const std::vector<std::pair<int, int>>& a, std::vector<std::pair<int, int>>& b) { std::copy(a.begin(), a.end(), b.begin()); } void SmartCopyPair(const std::vector<MyPair>& a, std::vector<MyPair>& b) { std::copy(a.begin(), a.end(), b.begin()); }
| | gcc.godbolt.org
0.2 parsecs away

Travel
| | template<class T1, class T2> struct MyPair { T1 first; T2 second; static constexpr bool has_references = std::is_reference_v<T1> || std::is_reference_v<T2>; MyPair(const T1& x, const T2& y) : first(x), second(y) {} MyPair& operator=(const MyPair&) requires(!has_references) = default; MyPair& operator=(const MyPair& other) requires(has_references) { first = other.first; second = other.second; return *this; } }; int main() { int x = 10; MyPair<int&, int> a(x, 5); MyPair<int&, int> b(x, 10); b = a; }
| | gcc.godbolt.org
0.1 parsecs away

Travel
| | template<class T1, class T2> struct MyPair { T1 first; T2 second; static constexpr bool has_references = std::is_reference_v<T1> || std::is_reference_v<T2>; MyPair(const MyPair& other) = default; MyPair(const T1& x, const T2& y) : first(x), second(y) {} MyPair& operator=(const MyPair&) requires(!has_references) = default; MyPair& operator=(const MyPair& other) requires(has_references) { this->~MyPair(); return * new (this) MyPair(other); } }; int main() { int x = 10; int y = 1; MyPair<int&, int> a(x, 5); MyPair<int&, int> b(y, 10); b = a; return b.first; // 10 }
| | blog.nodraak.fr
14.4 parsecs away

Travel
| [AI summary] A developer discusses creating a simple frontend game using the Rust programming language and WebAssembly to demonstrate performance and modularity.