Index: uspace/lib/cpp/include/impl/complex.hpp
===================================================================
--- uspace/lib/cpp/include/impl/complex.hpp	(revision 47203ee351cd600dff8e407328a48329a7a027d8)
+++ uspace/lib/cpp/include/impl/complex.hpp	(revision 8794d1676282d452785f48495466bc39e9c558c4)
@@ -30,5 +30,939 @@
 #define LIBCPP_COMPLEX
 
-#error "<complex> is not implemented"
+#include <iosfwd>
+
+namespace std
+{
+    template<class T>
+    class complex
+    {
+        public:
+            using value_type = T;
+
+            constexpr complex(const value_type& re = value_type{},
+                              const value_type& im = value_type{})
+                : real_{re}, imag_{im}
+            { /* DUMMY BODY */ }
+
+            constexpr complex(const complex& other)
+                : real_{other.real_}, imag_{other.imag_}
+            { /* DUMMY BODY */ }
+
+            template<class U>
+            constexpr complex(const complex<U>& other)
+                : real_(other.real_), imag_(other.imag_)
+            { /* DUMMY BODY */ }
+
+            constexpr value_type real() const
+            {
+                return real_;
+            }
+
+            void real(value_type val)
+            {
+                real_ = val;
+            }
+
+            constexpr value_type imag() const
+            {
+                return imag_;
+            }
+
+            void imag(value_type val)
+            {
+                imag_ = val;
+            }
+
+            complex& operator=(const value_type& val)
+            {
+                real_ = val;
+                imag_ = value_type{};
+
+                return *this;
+            }
+
+            complex& operator+=(const value_type& val)
+            {
+                real_ += val;
+
+                return *this;
+            }
+
+            complex& operator-=(const value_type& val)
+            {
+                real_ -= val;
+
+                return *this;
+            }
+
+            complex& operator*=(const value_type& val)
+            {
+                real_ *= val;
+                imag_ *= val;
+
+                return *this;
+            }
+
+            complex& operator/=(const value_type& val)
+            {
+                real_ /= val;
+                imag_ /= val;
+
+                return *this;
+            }
+
+            complex& operator=(const complex& other)
+            {
+                real_ = other.real_;
+                imag_ = other.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator=(const complex<U>& rhs)
+            {
+                real_ = rhs.real_;
+                imag_ = rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator+=(const complex<U>& rhs)
+            {
+                real_ += rhs.real_;
+                imag_ += rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator-=(const complex<U>& rhs)
+            {
+                real_ -= rhs.real_;
+                imag_ -= rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator*=(const complex<U>& rhs)
+            {
+                real_ = real_ * rhs.real_ - imag_ * rhs.imag_;
+                imag_ = real_ * rhs.imag_ - imag_ * rhs.real_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator/=(const complex<U>& rhs)
+            {
+                real_ = (real_ * rhs.real_ + imag_ * rhs.imag_)
+                      / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
+                imag_ = (imag_ * rhs.real_ - real_ * rhs.imag_)
+                      / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
+
+                return *this;
+            }
+
+        private:
+            value_type real_;
+            value_type imag_;
+    };
+
+    template<>
+    class complex<float>
+    {
+        public:
+            using value_type = float;
+
+            constexpr complex(const value_type& re = value_type{},
+                              const value_type& im = value_type{})
+                : real_{re}, imag_{im}
+            { /* DUMMY BODY */ }
+
+            constexpr complex(const complex& other)
+                : real_{other.real_}, imag_{other.imag_}
+            { /* DUMMY BODY */ }
+
+            template<class U>
+            constexpr complex(const complex<U>& other)
+                : real_(other.real_), imag_(other.imag_)
+            { /* DUMMY BODY */ }
+
+            constexpr value_type real() const
+            {
+                return real_;
+            }
+
+            void real(value_type val)
+            {
+                real_ = val;
+            }
+
+            constexpr value_type imag() const
+            {
+                return imag_;
+            }
+
+            void imag(value_type val)
+            {
+                imag_ = val;
+            }
+
+            complex& operator=(const value_type& val)
+            {
+                real_ = val;
+                imag_ = value_type{};
+
+                return *this;
+            }
+
+            complex& operator+=(const value_type& val)
+            {
+                real_ += val;
+
+                return *this;
+            }
+
+            complex& operator-=(const value_type& val)
+            {
+                real_ -= val;
+
+                return *this;
+            }
+
+            complex& operator*=(const value_type& val)
+            {
+                real_ *= val;
+                imag_ *= val;
+
+                return *this;
+            }
+
+            complex& operator/=(const value_type& val)
+            {
+                real_ /= val;
+                imag_ /= val;
+
+                return *this;
+            }
+
+            complex& operator=(const complex& other)
+            {
+                real_ = other.real_;
+                imag_ = other.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator=(const complex<U>& rhs)
+            {
+                real_ = rhs.real_;
+                imag_ = rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator+=(const complex<U>& rhs)
+            {
+                real_ += rhs.real_;
+                imag_ += rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator-=(const complex<U>& rhs)
+            {
+                real_ -= rhs.real_;
+                imag_ -= rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator*=(const complex<U>& rhs)
+            {
+                real_ = real_ * rhs.real_ - imag_ * rhs.imag_;
+                imag_ = real_ * rhs.imag_ - imag_ * rhs.real_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator/=(const complex<U>& rhs)
+            {
+                real_ = (real_ * rhs.real_ + imag_ * rhs.imag_)
+                      / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
+                imag_ = (imag_ * rhs.real_ - real_ * rhs.imag_)
+                      / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
+
+                return *this;
+            }
+
+        private:
+            value_type real_;
+            value_type imag_;
+    };
+
+    template<>
+    class complex<double>
+    {
+        public:
+            using value_type = double;
+
+            constexpr complex(const value_type& re = value_type{},
+                              const value_type& im = value_type{})
+                : real_{re}, imag_{im}
+            { /* DUMMY BODY */ }
+
+            constexpr complex(const complex& other)
+                : real_{other.real_}, imag_{other.imag_}
+            { /* DUMMY BODY */ }
+
+            template<class U>
+            constexpr complex(const complex<U>& other)
+                : real_(other.real_), imag_(other.imag_)
+            { /* DUMMY BODY */ }
+
+            constexpr value_type real() const
+            {
+                return real_;
+            }
+
+            void real(value_type val)
+            {
+                real_ = val;
+            }
+
+            constexpr value_type imag() const
+            {
+                return imag_;
+            }
+
+            void imag(value_type val)
+            {
+                imag_ = val;
+            }
+
+            complex& operator=(const value_type& val)
+            {
+                real_ = val;
+                imag_ = value_type{};
+
+                return *this;
+            }
+
+            complex& operator+=(const value_type& val)
+            {
+                real_ += val;
+
+                return *this;
+            }
+
+            complex& operator-=(const value_type& val)
+            {
+                real_ -= val;
+
+                return *this;
+            }
+
+            complex& operator*=(const value_type& val)
+            {
+                real_ *= val;
+                imag_ *= val;
+
+                return *this;
+            }
+
+            complex& operator/=(const value_type& val)
+            {
+                real_ /= val;
+                imag_ /= val;
+
+                return *this;
+            }
+
+            complex& operator=(const complex& other)
+            {
+                real_ = other.real_;
+                imag_ = other.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator=(const complex<U>& rhs)
+            {
+                real_ = rhs.real_;
+                imag_ = rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator+=(const complex<U>& rhs)
+            {
+                real_ += rhs.real_;
+                imag_ += rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator-=(const complex<U>& rhs)
+            {
+                real_ -= rhs.real_;
+                imag_ -= rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator*=(const complex<U>& rhs)
+            {
+                real_ = real_ * rhs.real_ - imag_ * rhs.imag_;
+                imag_ = real_ * rhs.imag_ - imag_ * rhs.real_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator/=(const complex<U>& rhs)
+            {
+                real_ = (real_ * rhs.real_ + imag_ * rhs.imag_)
+                      / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
+                imag_ = (imag_ * rhs.real_ - real_ * rhs.imag_)
+                      / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
+
+                return *this;
+            }
+
+        private:
+            value_type real_;
+            value_type imag_;
+    };
+
+    template<>
+    class complex<long double>
+    {
+        public:
+            using value_type = long double;
+
+            constexpr complex(const value_type& re = value_type{},
+                              const value_type& im = value_type{})
+                : real_{re}, imag_{im}
+            { /* DUMMY BODY */ }
+
+            constexpr complex(const complex& other)
+                : real_{other.real_}, imag_{other.imag_}
+            { /* DUMMY BODY */ }
+
+            template<class U>
+            constexpr complex(const complex<U>& other)
+                : real_(other.real_), imag_(other.imag_)
+            { /* DUMMY BODY */ }
+
+            constexpr value_type real() const
+            {
+                return real_;
+            }
+
+            void real(value_type val)
+            {
+                real_ = val;
+            }
+
+            constexpr value_type imag() const
+            {
+                return imag_;
+            }
+
+            void imag(value_type val)
+            {
+                imag_ = val;
+            }
+
+            complex& operator=(const value_type& val)
+            {
+                real_ = val;
+                imag_ = value_type{};
+
+                return *this;
+            }
+
+            complex& operator+=(const value_type& val)
+            {
+                real_ += val;
+
+                return *this;
+            }
+
+            complex& operator-=(const value_type& val)
+            {
+                real_ -= val;
+
+                return *this;
+            }
+
+            complex& operator*=(const value_type& val)
+            {
+                real_ *= val;
+                imag_ *= val;
+
+                return *this;
+            }
+
+            complex& operator/=(const value_type& val)
+            {
+                real_ /= val;
+                imag_ /= val;
+
+                return *this;
+            }
+
+            complex& operator=(const complex& other)
+            {
+                real_ = other.real_;
+                imag_ = other.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator=(const complex<U>& rhs)
+            {
+                real_ = rhs.real_;
+                imag_ = rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator+=(const complex<U>& rhs)
+            {
+                real_ += rhs.real_;
+                imag_ += rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator-=(const complex<U>& rhs)
+            {
+                real_ -= rhs.real_;
+                imag_ -= rhs.imag_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator*=(const complex<U>& rhs)
+            {
+                real_ = real_ * rhs.real_ - imag_ * rhs.imag_;
+                imag_ = real_ * rhs.imag_ - imag_ * rhs.real_;
+
+                return *this;
+            }
+
+            template<class U>
+            complex& operator/=(const complex<U>& rhs)
+            {
+                real_ = (real_ * rhs.real_ + imag_ * rhs.imag_)
+                      / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
+                imag_ = (imag_ * rhs.real_ - real_ * rhs.imag_)
+                      / (rhs.real_ * rhs.real_ + rhs.imag_ * rhs.imag_);
+
+                return *this;
+            }
+
+        private:
+            value_type real_;
+            value_type imag_;
+    };
+
+    /**
+     * 26.4.6, operators:
+     */
+
+    template<class T>
+    complex<T> operator+(const complex<T>& lhs, const complex<T>& rhs)
+    {
+        return complex<T>{lhs} += rhs;
+    }
+
+    template<class T>
+    complex<T> operator+(const complex<T>& lhs, const T& rhs)
+    {
+        return complex<T>{lhs} += rhs;
+    }
+
+    template<class T>
+    complex<T> operator+(const T& lhs, const complex<T>& rhs)
+    {
+        return complex<T>{lhs} += rhs;
+    }
+
+    template<class T>
+    complex<T> operator-(const complex<T>& lhs, const complex<T>& rhs)
+    {
+        return complex<T>{lhs} -= rhs;
+    }
+
+    template<class T>
+    complex<T> operator-(const complex<T>& lhs, const T& rhs)
+    {
+        return complex<T>{lhs} -= rhs;
+    }
+
+    template<class T>
+    complex<T> operator-(const T& lhs, const complex<T>& rhs)
+    {
+        return complex<T>{lhs} -= rhs;
+    }
+
+    template<class T>
+    complex<T> operator*(const complex<T>& lhs, const complex<T>& rhs)
+    {
+        return complex<T>{lhs} *= rhs;
+    }
+
+    template<class T>
+    complex<T> operator*(const complex<T>& lhs, const T& rhs)
+    {
+        return complex<T>{lhs} *= rhs;
+    }
+
+    template<class T>
+    complex<T> operator*(const T& lhs, const complex<T>& rhs)
+    {
+        return complex<T>{lhs} *= rhs;
+    }
+
+    template<class T>
+    complex<T> operator/(const complex<T>& lhs, const complex<T>& rhs)
+    {
+        return complex<T>{lhs} /= rhs;
+    }
+
+    template<class T>
+    complex<T> operator/(const complex<T>& lhs, const T& rhs)
+    {
+        return complex<T>{lhs} /= rhs;
+    }
+
+    template<class T>
+    complex<T> operator/(const T& lhs, const complex<T>& rhs)
+    {
+        return complex<T>{lhs} /= rhs;
+    }
+
+    template<class T>
+    complex<T> operator+(const complex<T>& c)
+    {
+        return complex<T>{c};
+    }
+
+    template<class T>
+    complex<T> operator-(const complex<T>& c)
+    {
+        return complex<T>{-c.real(), -c.imag()};
+    }
+
+    template<class T>
+    constexpr bool operator==(const complex<T>& lhs, const complex<T>& rhs)
+    {
+        return lhs.real() == rhs.real() && lhs.imag() == rhs.imag();
+    }
+
+    template<class T>
+    constexpr bool operator==(const complex<T>& lhs, const T& rhs)
+    {
+        return lhs.real() == rhs && lhs.imag() == T{};
+    }
+
+    template<class T>
+    constexpr bool operator==(const T& lhs, const complex<T>& rhs)
+    {
+        return lhs == rhs.real() && T{} == rhs.imag();
+    }
+
+    template<class T>
+    constexpr bool operator!=(const complex<T>& lhs, const complex<T>& rhs)
+    {
+        return lhs.real() != rhs.real() || lhs.imag() != rhs.imag();
+    }
+
+    template<class T>
+    constexpr bool operator!=(const complex<T>& lhs, const T& rhs)
+    {
+        return lhs.real() != rhs || lhs.imag() != T{};
+    }
+
+    template<class T>
+    constexpr bool operator!=(const T& lhs, const complex<T>& rhs)
+    {
+        return lhs != rhs.real() || T{} != rhs.imag();
+    }
+
+    template<class T, class Char, class Traits>
+    basic_istream<Char, Traits>& operator>>(basic_istream<Char, Traits>& is,
+                                            const complex<T>& c)
+    {
+        // TODO: implement
+    }
+
+    template<class T, class Char, class Traits>
+    basic_ostream<Char, Traits>& operator<<(basic_ostream<Char, Traits>& os,
+                                            const complex<T>& c)
+    {
+        basic_ostringstream<Char, Traits> oss{};
+        oss.flags(os.flags());
+        oss.imbue(os.getloc());
+        oss.precision(os.precision());
+
+        oss << "(" << c.real() << "," << c.imag() << ")";
+
+        return os << oss.str();
+    }
+
+    /**
+     * 26.4.7, values:
+     */
+
+    template<class T>
+    constexpr T real(const complex<T>& c)
+    {
+        return c.real();
+    }
+
+    template<class T>
+    constexpr T imag(const complex<T>& c)
+    {
+        return c.imag();
+    }
+
+    template<class T>
+    T abs(const complex<T>& c)
+    {
+        return c.real() * c.real() + c.imag() * c.imag();
+    }
+
+    template<class T>
+    T arg(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    T norm(const complex<T>& c)
+    {
+        return abs(c) * abs(c);
+    }
+
+    template<class T>
+    complex<T> conj(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> proj(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> polar(const T&, const T& = T{})
+    {
+        // TODO: implement
+        return complex<T>{};
+    }
+
+    /**
+     * 26.4.8, transcendentals:
+     */
+
+    template<class T>
+    complex<T> acos(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> asin(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> atan(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> acosh(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> asinh(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> atanh(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> cos(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> cosh(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> exp(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> log(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> log10(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> pow(const complex<T>& base, const T& exp)
+    {
+        // TODO: implement
+        return base;
+    }
+
+    template<class T>
+    complex<T> pow(const complex<T>& base, const complex<T>& exp)
+    {
+        // TODO: implement
+        return base;
+    }
+
+    template<class T>
+    complex<T> pow(const T& base, const complex<T>& exp)
+    {
+        // TODO: implement
+        return complex<T>{base};
+    }
+
+    template<class T>
+    complex<T> sin(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> sinh(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> sqrt(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> tan(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    template<class T>
+    complex<T> tanh(const complex<T>& c)
+    {
+        // TODO: implement
+        return c;
+    }
+
+    /**
+     * 26.4.10, complex literals:
+     */
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wliteral-suffix"
+inline namespace literals {
+inline namespace complex_literals
+{
+    constexpr complex<long double> operator ""il(long double val)
+    {
+        return complex<long double>{0.0L, val};
+    }
+
+    constexpr complex<long double> operator ""il(unsigned long long val)
+    {
+        return complex<long double>{0.0L, static_cast<long double>(val)};
+    }
+
+    constexpr complex<double> operator ""i(long double val)
+    {
+        return complex<double>{0.0, static_cast<double>(val)};
+    }
+
+    constexpr complex<double> operator ""i(unsigned long long val)
+    {
+        return complex<double>{0.0, static_cast<double>(val)};
+    }
+
+    constexpr complex<float> operator ""if(long double val)
+    {
+        return complex<float>{0.0f, static_cast<float>(val)};
+    }
+
+    constexpr complex<float> operator ""if(unsigned long long val)
+    {
+        return complex<float>{0.0f, static_cast<float>(val)};
+    }
+}}
+#pragma GCC diagnostic pop
+}
 
 #endif
