/explore

Click through on any links that interest you or select the planets on the right to continue exploring the Outer Web.
You are here

rust.godbolt.org
| | gcc.godbolt.org

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; }
0.2 parsecs

Travel
| |
| | gcc.godbolt.org

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()); }
0.1 parsecs

Travel
| |
| | gcc.godbolt.org

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 }
0.1 parsecs

Travel
| |
| | 2ality.com

This blog post explains the difference between JavaScript and ECMAScript. And the differences between ECMAScript.next, ECMAScript 6 and ECMAScript Harmony.
25.8 parsecs

Travel
|