>Ruins your compile times
Ruins your compile times
Unbeatable runtime, though.
Yeah right.
It ruins everything else about your project too.
// A sample standard C++20 program that prints
// the first N Pythagorean triples.
#include
#include
#include // New header!
using namespace std;
// maybe_view defines a view over zero or one
// objects.
template
struct maybe_view : view_interface {
maybe_view() = default;
maybe_view(T t) : data_(std::move(t)) {
}
T const *begin() const noexcept {
return data_ ? &*data_ : nullptr;
}
T const *end() const noexcept {
return data_ ? &*data_ + 1 : nullptr;
}
private:
optional data_{};
};
// "for_each" creates a new view by applying a
// transformation to each element in an input
// range, and flattening the resulting range of
// ranges.
// (This uses one syntax for constrained lambdas
// in C++20.)
inline constexpr auto for_each =
[](R&& r, Fun fun)
requires Range {
return std::forward(r)
| view::transform(std::move(fun))
| view::join;
};
// "yield_if" takes a bool and a value and
// returns a view of zero or one elements.
inline constexpr auto yield_if =
[](bool b, T x) {
return b ? maybe_view{std::move(x)}
: maybe_view{};
};
int main() {
// Define an infinite range of all the
// Pythagorean triples:
using view::iota;
auto triples =
for_each(iota(1), [](int z) {
return for_each(iota(1, z+1), [=](int x) {
return for_each(iota(x, z+1), [=](int y) {
return yield_if(x*x + y*y == z*z,
make_tuple(x, y, z));
});
});
});
// Display the first 10 triples
for(auto triple : triples | view::take(10)) {
cout
>implying compile time is the most important thing
Compile times hardly come into the economic equation. The fact of the matter is that the time taken to add a feature to a program is the chief economic concern. C++ is a nice halfway house between python and C which enables more bang per line of code.
Enjoy your bounds overflow.
>Compile times hardly come into the economic equation
Based retard.
>bruteforcing Pythagorean triples
Please don't use C++ if you didn't graduate from high school.
It wasn't written by him, it was written by the maintainers of your pajeet language.
That's not GNU Crap Compiler
Imagine having this much free time.
use forward declarations and a proper build system and you won't have this problem
I don't have this problem in any other language.
Only in retard C++ APIs I have to use.
"other languages" also don't have anywhere near the metaprogramming capabilities
Who gives a fuck
Confirmed OP is a poo Java programmer
make -j4 ???
People who want to create complex highly efficient programs give a fuck. If you're a baby programmer that's fine too though.
Millions of people
Just because you can doesn't mean you should
Anyone else like a good long compile? Especially with my own stuff. A 3 second compile just makes me feel satisfied.
You're doing something wrong if your code takes 3s to compile every time
#include
alright hold my latte