C++人该知道的N个问题与做法:让operator=返回一个& to *this

本文深入探讨了C++中连锁赋值的原理及其背后的右结合律特性,通过实例解释了如何实现“连锁赋值”。此外,文章还讲解了操作符重载,特别是赋值操作符和复合赋值操作符的重载技巧,以及为何返回引用的重要性。

关于赋值,你可以把它们写成连锁形式:

int x, y, z;
x=y=z=5;

赋值采用右结合律,所以上述连锁赋值被解析为:x=(y=(z=5));
这里5先被赋值给z,然后其结果(更新后的z)再被赋值给y,然后其结果(更新后的y)再被赋值给x
为了实现“连锁赋值”,赋值操作符必须返回一个 “引用”,指向操作符的左侧实参。

class Color{
 public:
    Color& operator=(const Color& rhs){   //返回一个&,指向当前对象
        ...
        return* this;   //返回左侧对象
    }
};
class Color{
 public:
    Color& operator+=(const Color& rhs)    //这个方式也适用于+=,-=,*=等等
         return* this;
    }
};

注意,这只是一个约定,并不是强制性的。如果不遵循它,代码一样可通过编译。然而这份约定被所有内置类型和标准程序库提供的类型如 string, vector, complex,tr1:: shared_ptr等共同遵守。因此除非你有一个标新立异的好理由,不然还是随众吧。

#include <thread> #include <functional> #include <vector> #include <queue> #include <condition_variable> #include <mutex> #include <atomic> class CustomThread { std::thread m_thread; bool m_isRunning; std::function<void()> m_func; public: CustomThread():m_isRunning(false){} template<typename F,typename... Args> CustomThread(F&& f, Args&&...args) { m_isRunning = true; m_func = std::bind(std::forward<F>(f), std::forward<Args>(args)...); m_thread = std::thread(&CustomThread::run,this); } void run() { if (m_isRunning && m_func) { m_func(); m_isRunning = false;; } } template<typename F,typename... Args> void Start(F&& f, Args&&... args) { m_isRunning = true; m_func = std::bind(std::forward<F>(f), std::forward<Args>(args)...); m_thread = std::thread(&CustomThread::run, this); } void Stop() { m_isRunning = false; if (m_thread.joinable()) { m_thread.join(); } } }; class ThreadPool { private: std::vector<CustomThread> threads; std::queue<std::function<void()>> tasks; std::condition_variable cv; std::mutex mtx; std::atomic<bool> isRunning; int threadCount; public: void threadFunc() { while (isRunning) { std::function<void()> task; { std::unique_lock<std::mutex> lock(mtx); cv.wait(lock, [=] { return !isRunning || !tasks.empty(); }); if (!isRunning && tasks.empty()) { return; } task= tasks.front(); tasks.pop(); } task(); } } public: ThreadPool(int threadCnt) :threadCount(threadCnt) { isRunning = true; for (int i = 0; i < threadCnt; i++) { threads.emplace_back(new CustomThread(&ThreadPool::threadFunc,this)); } } template<typename F,typename... Args> void addTask(F&& f, Args&&...args) { if (isRunning) { std::unique_lock<std::mutex> lock(mtx); tasks.emplace(std::bind(std::forward<F>(f),std::forward<Args>(args)...)); cv.notify_one(); } } void Stop() { if (isRunning) { isRunning = false; for (int i = 0; i < threads.size(); i++) { threads[i].Stop(); } cv.notify_all(); } } };生成开始于 12:29... 1>------ 已启动生成: 项目: AlgoPractice, 配置: Debug x64 ------ 1>正在验证源 1>正在将源远程复制到“47.121.29.36” 1>正在验证体系结构 1>正在验证体系结构 1>正在启动远程生成 1>正在编译源: 1>main.cpp 1>bash : warning : setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8) 1>D:\VS2022\AlgoPractice\main.cpp(110,43): warning : comparison of integer expressions of different signedness: 'int' and 'std::vector<CustomThread>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 1>D:\VS2022\AlgoPractice\main.cpp(110,43): warning : 110 | for (int i = 0; i < threads.size(); i++) 1>D:\VS2022\AlgoPractice\main.cpp(110,43): warning : | ~~^~~~~~~~~~~~~~~~ 1>/usr/include/c++/11/functional(464,15): error : no type named 'type' in 'struct std::result_of<CustomThread*&()>' 1>/usr/include/c++/11/functional(464,15): error : 464 | using _Res_type_impl 1>/usr/include/c++/11/functional(464,15): error : | ^~~~~~~~~~~~~~ 1>/usr/include/c++/11/functional(464,15): error : no type named 'type' in 'struct std::result_of<CustomThread*&()>' 1>D:\VS2022\AlgoPractice\main.cpp(21,24): error : no match for 'operator=' (operand types are 'std::function<void()>' and 'std::_Bind_helper<false, CustomThread*>::type') 1>/usr/include/c++/11/bits/std_function.h(530,9): message : candidate: 'template<class _Functor> std::function<_Res(_ArgTypes ...)>::_Requires<std::function<_Res(_ArgTypes ...)>::_Callable<_Functor>, std::function<_Res(_ArgTypes ...)>&> std::function<_Res(_ArgTypes ...)>::operator=(_Functor&&) [with _Functor = _Functor; _Res = void; _ArgTypes = {}]' 1>/usr/include/c++/11/bits/std_function.h(530,9): message : 530 | operator=(_Functor&& __f) 1>/usr/include/c++/11/bits/std_function.h(530,9): message : | ^~~~~~~~ 1>/usr/include/c++/11/bits/std_function.h(530,9): message : template argument deduction/substitution failed: 1>/usr/include/c++/11/type_traits(2205,11): error : no type named 'type' in 'struct std::enable_if<false, std::function<void()>&>' 1>/usr/include/c++/11/bits/std_function.h(540,9): message : candidate: 'template<class _Functor> std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::reference_wrapper<_Functor>) [with _Functor = _Functor; _Res = void; _ArgTypes = {}]' 1>/usr/include/c++/11/bits/std_function.h(540,9): message : 540 | operator=(reference_wrapper<_Functor> __f) noexcept 1>/usr/include/c++/11/bits/std_function.h(540,9): message : | ^~~~~~~~ 1>/usr/include/c++/11/bits/std_function.h(540,9): message : template argument deduction/substitution failed: 1>D:\VS2022\AlgoPractice\main.cpp(21,24): message : 'std::_Bind<CustomThread*()>' is not derived from 'std::reference_wrapper<_Tp>' 1>/usr/include/c++/11/bits/std_function.h(469,7): message : candidate: 'std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(const std::function<_Res(_ArgTypes ...)>&) [with _Res = void; _ArgTypes = {}]' 1>/usr/include/c++/11/bits/std_function.h(469,7): message : 469 | operator=(const function& __x) 1>/usr/include/c++/11/bits/std_function.h(469,7): message : | ^~~~~~~~ 1>/usr/include/c++/11/bits/std_function.h(469,33): message : no known conversion for argument 1 from 'std::_Bind_helper<false, CustomThread*>::type' to 'const std::function<void()>&' 1>/usr/include/c++/11/bits/std_function.h(469,33): message : 469 | operator=(const function& __x) 1>/usr/include/c++/11/bits/std_function.h(469,33): message : | ~~~~~~~~~~~~~~~~^~~ 1>/usr/include/c++/11/bits/std_function.h(487,7): message : candidate: 'std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::function<_Res(_ArgTypes ...)>&&) [with _Res = void; _ArgTypes = {}]' 1>/usr/include/c++/11/bits/std_function.h(487,7): message : 487 | operator=(function&& __x) noexcept 1>/usr/include/c++/11/bits/std_function.h(487,7): message : | ^~~~~~~~ 1>/usr/include/c++/11/bits/std_function.h(487,28): message : no known conversion for argument 1 from 'std::_Bind_helper<false, CustomThread*>::type' to 'std::function<void()>&&' 1>/usr/include/c++/11/bits/std_function.h(487,28): message : 487 | operator=(function&& __x) noexcept 1>/usr/include/c++/11/bits/std_function.h(487,28): message : | ~~~~~~~~~~~^~~ 1>/usr/include/c++/11/bits/std_function.h(501,7): message : candidate: 'std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::nullptr_t) [with _Res = void; _ArgTypes = {}; std::nullptr_t = std::nullptr_t]' 1>/usr/include/c++/11/bits/std_function.h(501,7): message : 501 | operator=(nullptr_t) noexcept 1>/usr/include/c++/11/bits/std_function.h(501,7): message : | ^~~~~~~~ 1>/usr/include/c++/11/bits/std_function.h(501,17): message : no known conversion for argument 1 from 'std::_Bind_helper<false, CustomThread*>::type' to 'std::nullptr_t' 1>/usr/include/c++/11/bits/std_function.h(501,17): message : 501 | operator=(nullptr_t) noexcept 1>/usr/include/c++/11/bits/std_function.h(501,17): message : | ^~~~~~~~~ 1>bash : warning : setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8) 1>已完成生成项目“AlgoPractice.vcxproj”的操作 - 失败。 ========== 生成: 0 成功,1 失败,0 最新,0 已跳过 ========== ========== 生成 于 12:29 完成,耗时 05.579 秒 ==========
最新发布
12-05
#ifndef VEC3_H #define VEC3_H #include<cmath> class vec3 { public: vec3():e{0,0,0}{}; vec3(double e0,double e1,double e2):e{e0,e1,e2}{}; double x()const{return e[0];} double y()const{return e[1];} double z()const{return e[2];} double r()const{return e[0];} double g()const{return e[1];} double b()const{return e[2];} const vec3& operator +()const{return *this;} vec3 operator-()const{return vec3(-e[0],-e[1],-e[2]);} double operator[](int i)const {return e[i];} double& operator[](int i){return e[i];} vec3& operator+=(const vec3& v); vec3& operator-=(const vec3& v); vec3& operator*=(const vec3& v); vec3& operator/=(const vec3& v); vec3& operator*=(const double t); vec3& operator/=(const double t); double length()const{ return sqrt(lengthSquared()); } double lengthSquared()const{ return e[0]*e[0]+e[1]*e[1]+e[2]*e[2]; } public: double e[3]; }; vec3 &vec3::operator+=(const vec3 &v){ e[0]+v.e[0]; e[1]+v.e[1]; e[2]+v.e[2]; return *this; } inline vec3 operator+(const vec3 &v1,const vec3 &v2){ return vec3(v1.e[0]+v2.e[0],v1.e[1]+v2.e[1],v1.e[2]+v2.e[2]); } inline vec3 operator-(const vec3 &v1,const vec3 &v2){ return vec3(v1.e[0]-v2.e[0],v1.e[1]-v2.e[1],v1.e[2]-v2.e[2]); } inline vec3 operator*(const vec3 &v1,const vec3 &v2){ return vec3(v1.e[0]*v2.e[0],v1.e[1]*v2.e[1],v1.e[2]*v2.e[2]); } inline vec3 operator/(const vec3 &v1,const vec3 &v2){ return vec3(v1.e[0]/v2.e[0],v1.e[1]/v2.e[1],v1.e[2]/v2.e[2]); } vec3 &vec3::operator*=(const double t){ e[0]*=t; e[1]*=t; e[2]*=t; return *this; } vec3 &vec3::operator/=(const double t){ return *this *=1/t; } inline double dot(const vec3 &v1,const vec3 &v2){ return v1.e[0]*v2.e[0],v1.e[1]*v2.e[1],v1.e[2]*v2.e[2]; } inline vec3 cross(const vec3 &v1,const vec3 &v2){ return vec3(v1.e[1]*v2.e[2]-v1.e[2]*v2.e[1], -v1.e[0]*v2.e[2]-v1.e[2]*v2.e[0], v1.e[0]*v2.e[1]-v1.e[1]*v2.e[0]); } inline vec3 unitVector(vec3 v){ return v/v.length(); } using point3=vec3; using color=vec3; #if 0 vec3& vec3::operator*=(const vec3& v) { for (int i = 0; i < 3; ++i) { e[i]*v.e[i]; } return *this; } vec3& vec3::operator/=(const vec3& v) { for (int i = 0; i < 3; ++i) { e[i]*v.e[i]; } return *this; } #endif #endif // VEC3_H E:\Code\Study\QTCode\QTStudyLoad\RayTracing\vec3.h:83: error: no match for 'operator/' (operand types are 'vec3' and 'double') In file included from E:/Code/Study/QTCode/QTStudyLoad/RayTracing/vec3.cpp:1: E:/Code/Study/QTCode/QTStudyLoad/RayTracing/vec3.h: In function 'vec3 unitVector(vec3)': E:/Code/Study/QTCode/QTStudyLoad/RayTracing/vec3.h:83:13: error: no match for 'operator/' (operand types are 'vec3' and 'double') return v/v.length(); ~^~~~~~~~~~~ E:/Code/Study/QTCode/QTStudyLoad/RayTracing/vec3.h:59:13: note: candidate: 'vec3 operator/(const vec3&, const vec3&)' inline vec3 operator/(const vec3 &v1,const vec3 &v2){ ^~~~~~~~ E:/Code/Study/QTCode/QTStudyLoad/RayTracing/vec3.h:59:13: note: no known conversion for argument 2 from 'double' to 'const vec3&'
07-12
a.cpp: In constructor ‘BigInt::BigInt(std::string)’: a.cpp:9:31: error: expected ‘{’ at end of input 9 | BigInt(string s):number(s);//构造函数 | ^ a.cpp: In function ‘std::istream operator>>(std::istream, BigInt)’: a.cpp:14:16: error: ‘std::basic_istream<_CharT, _Traits>::basic_istream(std::basic_istream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]’ is protected within this context 14 | return in; | ^~ In file included from /usr/include/c++/11/iostream:40, from a.cpp:1: /usr/include/c++/11/istream:613:7: note: declared protected here 613 | basic_istream(basic_istream&& __rhs) | ^~~~~~~~~~~~~ a.cpp: In function ‘std::ostream operator>>(std::ostream, BigInt)’: a.cpp:19:16: error: ‘std::basic_ostream<_CharT, _Traits>::basic_ostream(std::basic_ostream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]’ is protected within this context 19 | return out; | ^~~ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:406:7: note: declared protected here 406 | basic_ostream(basic_ostream&& __rhs) | ^~~~~~~~~~~~~ a.cpp: In function ‘int main()’: a.cpp:46:16: error: no matching function for call to ‘BigInt::BigInt()’ 46 | BigInt a, b, c; | ^ a.cpp:9:5: note: candidate: ‘BigInt::BigInt(std::string)’ 9 | BigInt(string s):number(s);//构造函数 | ^~~~~~ a.cpp:9:5: note: candidate expects 1 argument, 0 provided a.cpp:6:7: note: candidate: ‘BigInt::BigInt(const BigInt&)’ 6 | class BigInt | ^~~~~~ a.cpp:6:7: note: candidate expects 1 argument, 0 provided a.cpp:6:7: note: candidate: ‘BigInt::BigInt(BigInt&&)’ a.cpp:6:7: note: candidate expects 1 argument, 0 provided a.cpp:46:19: error: no matching function for call to ‘BigInt::BigInt()’ 46 | BigInt a, b, c; | ^ a.cpp:9:5: note: candidate: ‘BigInt::BigInt(std::string)’ 9 | BigInt(string s):number(s);//构造函数 | ^~~~~~ a.cpp:9:5: note: candidate expects 1 argument, 0 provided a.cpp:6:7: note: candidate: ‘BigInt::BigInt(const BigInt&)’ 6 | class BigInt | ^~~~~~ a.cpp:6:7: note: candidate expects 1 argument, 0 provided a.cpp:6:7: note: candidate: ‘BigInt::BigInt(BigInt&&)’ a.cpp:6:7: note: candidate expects 1 argument, 0 provided a.cpp:46:22: error: no matching function for call to ‘BigInt::BigInt()’ 46 | BigInt a, b, c; | ^ a.cpp:9:5: note: candidate: ‘BigInt::BigInt(std::string)’ 9 | BigInt(string s):number(s);//构造函数 | ^~~~~~ a.cpp:9:5: note: candidate expects 1 argument, 0 provided a.cpp:6:7: note: candidate: ‘BigInt::BigInt(const BigInt&)’ 6 | class BigInt | ^~~~~~ a.cpp:6:7: note: candidate expects 1 argument, 0 provided a.cpp:6:7: note: candidate: ‘BigInt::BigInt(BigInt&&)’ a.cpp:6:7: note: candidate expects 1 argument, 0 provided a.cpp:47:14: error: use of deleted function ‘std::basic_istream<_CharT, _Traits>::basic_istream(const std::basic_istream<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]’ 47 | cin>>a>>b; | ^ In file included from /usr/include/c++/11/iostream:40, from a.cpp:1: /usr/include/c++/11/istream:611:7: note: declared here 611 | basic_istream(const basic_istream&) = delete; | ^~~~~~~~~~~~~ a.cpp:11:39: note: initializing argument 1 of ‘std::istream operator>>(std::istream, BigInt)’ 11 | friend istream operator>>(istream in,BigInt b) | ~~~~~~~~^~ a.cpp:49:13: error: no match for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘BigInt’) 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ~~~~^~~ | | | | | BigInt | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:108:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 108 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/11/ostream:108:36: note: no known conversion for argument 1 from ‘BigInt’ to ‘std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)’ {aka ‘std::basic_ostream<char>& (*)(std::basic_ostream<char>&)’} 108 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/ostream:117:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>; std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]’ 117 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/11/ostream:117:32: note: no known conversion for argument 1 from ‘BigInt’ to ‘std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)’ {aka ‘std::basic_ios<char>& (*)(std::basic_ios<char>&)’} 117 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/11/ostream:127:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 127 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/11/ostream:127:30: note: no known conversion for argument 1 from ‘BigInt’ to ‘std::ios_base& (*)(std::ios_base&)’ 127 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/11/ostream:166:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 166 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/11/ostream:166:23: note: no known conversion for argument 1 from ‘BigInt’ to ‘long int’ 166 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/11/ostream:170:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 170 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/11/ostream:170:32: note: no known conversion for argument 1 from ‘BigInt’ to ‘long unsigned int’ 170 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/11/ostream:174:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 174 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/11/ostream:174:23: note: no known conversion for argument 1 from ‘BigInt’ to ‘bool’ 174 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/11/ostream:829, from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/bits/ostream.tcc:91:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]’ 91 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/ostream.tcc:92:22: note: no known conversion for argument 1 from ‘BigInt’ to ‘short int’ 92 | operator<<(short __n) | ~~~~~~^~~ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:181:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 181 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/11/ostream:181:33: note: no known conversion for argument 1 from ‘BigInt’ to ‘short unsigned int’ 181 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/11/ostream:829, from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/bits/ostream.tcc:105:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]’ 105 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/ostream.tcc:106:20: note: no known conversion for argument 1 from ‘BigInt’ to ‘int’ 106 | operator<<(int __n) | ~~~~^~~ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:192:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 192 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/11/ostream:192:31: note: no known conversion for argument 1 from ‘BigInt’ to ‘unsigned int’ 192 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/11/ostream:201:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 201 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/11/ostream:201:28: note: no known conversion for argument 1 from ‘BigInt’ to ‘long long int’ 201 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/11/ostream:205:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 205 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/11/ostream:205:37: note: no known conversion for argument 1 from ‘BigInt’ to ‘long long unsigned int’ 205 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/11/ostream:220:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 220 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/11/ostream:220:25: note: no known conversion for argument 1 from ‘BigInt’ to ‘double’ 220 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/11/ostream:224:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 224 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/11/ostream:224:24: note: no known conversion for argument 1 from ‘BigInt’ to ‘float’ 224 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/11/ostream:232:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 232 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/11/ostream:232:30: note: no known conversion for argument 1 from ‘BigInt’ to ‘long double’ 232 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/11/ostream:245:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 245 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/11/ostream:245:30: note: no known conversion for argument 1 from ‘BigInt’ to ‘const void*’ 245 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/11/ostream:250:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]’ 250 | operator<<(nullptr_t) | ^~~~~~~~ /usr/include/c++/11/ostream:250:18: note: no known conversion for argument 1 from ‘BigInt’ to ‘std::nullptr_t’ 250 | operator<<(nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/11/ostream:829, from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/bits/ostream.tcc:119:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]’ 119 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/ostream.tcc:120:34: note: no known conversion for argument 1 from ‘BigInt’ to ‘std::basic_ostream<char>::__streambuf_type*’ {aka ‘std::basic_streambuf<char>*’} 120 | operator<<(__streambuf_type* __sbin) | ~~~~~~~~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/11/bits/basic_string.h:48, from /usr/include/c++/11/string:55, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/string_view:667:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::basic_string_view<_CharT, _Traits>)’ 667 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/11/string_view:667:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: ‘BigInt’ is not derived from ‘std::basic_string_view<_CharT, _Traits>’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/string:55, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/bits/basic_string.h:6531:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)’ 6531 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/11/bits/basic_string.h:6531:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: ‘BigInt’ is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/bits/ios_base.h:46, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/system_error:279:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::error_code&)’ 279 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) | ^~~~~~~~ /usr/include/c++/11/system_error:279:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘const std::error_code&’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:513:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT)’ 513 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) | ^~~~~~~~ /usr/include/c++/11/ostream:513:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: deduced conflicting types for parameter ‘_CharT’ (‘char’ and ‘BigInt’) 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:518:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char)’ 518 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/11/ostream:518:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘char’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:524:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char)’ 524 | operator<<(basic_ostream<char, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/11/ostream:524:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘char’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:530:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char)’ 530 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c) | ^~~~~~~~ /usr/include/c++/11/ostream:530:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘signed char’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:535:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char)’ 535 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) | ^~~~~~~~ /usr/include/c++/11/ostream:535:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘unsigned char’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:544:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, wchar_t)’ (deleted) 544 | operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:544:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘wchar_t’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:549:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char8_t)’ (deleted) 549 | operator<<(basic_ostream<char, _Traits>&, char8_t) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:549:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘char8_t’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:554:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char16_t)’ (deleted) 554 | operator<<(basic_ostream<char, _Traits>&, char16_t) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:554:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘char16_t’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:558:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char32_t)’ (deleted) 558 | operator<<(basic_ostream<char, _Traits>&, char32_t) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:558:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘char32_t’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:564:5: note: candidate: ‘template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(std::basic_ostream<wchar_t, _Traits>&, char8_t)’ (deleted) 564 | operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:564:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: mismatched types ‘wchar_t’ and ‘char’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:569:5: note: candidate: ‘template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(std::basic_ostream<wchar_t, _Traits>&, char16_t)’ (deleted) 569 | operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:569:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: mismatched types ‘wchar_t’ and ‘char’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:573:5: note: candidate: ‘template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(std::basic_ostream<wchar_t, _Traits>&, char32_t)’ (deleted) 573 | operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:573:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: mismatched types ‘wchar_t’ and ‘char’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:594:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*)’ 594 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) | ^~~~~~~~ /usr/include/c++/11/ostream:594:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: mismatched types ‘const _CharT*’ and ‘BigInt’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/ostream:829, from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/bits/ostream.tcc:321:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*)’ 321 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/11/bits/ostream.tcc:321:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘const char*’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:611:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*)’ 611 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/11/ostream:611:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘const char*’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:624:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*)’ 624 | operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s) | ^~~~~~~~ /usr/include/c++/11/ostream:624:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘const signed char*’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:629:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*)’ 629 | operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s) | ^~~~~~~~ /usr/include/c++/11/ostream:629:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘const unsigned char*’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:638:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const wchar_t*)’ (deleted) 638 | operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:638:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘const wchar_t*’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:643:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char8_t*)’ (deleted) 643 | operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:643:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘const char8_t*’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:648:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char16_t*)’ (deleted) 648 | operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:648:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘const char16_t*’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:652:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char32_t*)’ (deleted) 652 | operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:652:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: cannot convert ‘a’ (type ‘BigInt’) to type ‘const char32_t*’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:658:5: note: candidate: ‘template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(std::basic_ostream<wchar_t, _Traits>&, const char8_t*)’ (deleted) 658 | operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:658:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: mismatched types ‘wchar_t’ and ‘char’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:663:5: note: candidate: ‘template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(std::basic_ostream<wchar_t, _Traits>&, const char16_t*)’ (deleted) 663 | operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:663:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: mismatched types ‘wchar_t’ and ‘char’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:667:5: note: candidate: ‘template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(std::basic_ostream<wchar_t, _Traits>&, const char32_t*)’ (deleted) 667 | operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete; | ^~~~~~~~ /usr/include/c++/11/ostream:667:5: note: template argument deduction/substitution failed: a.cpp:49:15: note: mismatched types ‘wchar_t’ and ‘char’ 49 | cout<<a<<"+"<<b<<"="<<c<<endl; | ^ In file included from /usr/include/c++/11/iostream:39, from a.cpp:1: /usr/include/c++/11/ostream:750:5: note: candidate: ‘template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&)’ 750 | operator<<(_Ostream&& __os, const _Tp& __x) | ^~~~~~~~ /usr/include/c++/11/ostream:750:5: note: template argument deduction/substitution failed: /usr/include/c++/11/ostream: In substitution of ‘template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::basic_ostream<char>&; _Tp = BigInt]’: a.cpp:49:8: required from here /usr/include/c++/11/ostream:750:5: error: template constraint failure for ‘template<class _Os, class _Tp> requires (__derived_from_ios_base<_Os>) && requires(_Os& __os, const _Tp& __t) {__os << __t;} using __rvalue_stream_insertion_t = _Os&&’ /usr/include/c++/11/ostream:750:5: note: constraints not satisfied /usr/include/c++/11/ostream: In substitution of ‘template<class _Os, class _Tp> requires (__derived_from_ios_base<_Os>) && requires(_Os& __os, const _Tp& __t) {__os << __t;} using __rvalue_stream_insertion_t = _Os&& [with _Os = std::basic_ostream<char>&; _Tp = BigInt]’: /usr/include/c++/11/ostream:750:5: required by substitution of ‘template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::basic_ostream<char>&; _Tp = BigInt]’ a.cpp:49:8: required from here /usr/include/c++/11/ostream:717:13: required for the satisfaction of ‘__derived_from_ios_base<_Os>’ [with _Os = std::basic_ostream<char, std::char_traits<char> >&] /usr/include/c++/11/ostream:717:39: note: the expression ‘is_class_v<_Tp> [with _Tp = std::basic_ostream<char, std::char_traits<char> >&]’ evaluated to ‘false’ 717 | concept __derived_from_ios_base = is_class_v<_Tp> | ^~~~~~~~~~~~~~~
11-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿尔兹

如果觉得有用就推荐给你的朋友吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值