Skip to main content
Code Review

Return to Question

Commonmark migration
Source Link

This code can be found in the [archive here][1]archive here. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.

Removed raise functions from above code. [1]: http://webEbenezer.net/build_integration.html

This code can be found in the [archive here][1]. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.

Removed raise functions from above code. [1]: http://webEbenezer.net/build_integration.html

This code can be found in the archive here. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.

Removed raise functions from above code.

deleted 93 characters in body
Source Link

This code can be found in the archive here [archive here][1]. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.

#ifndef CMW_ErrorWords_hh
#define CMW_ErrorWords_hh
#include <exception>
#include <string>
namespace cmw {
class failure : public ::std::exception {
 ::std::string whatStr;
public:
 explicit failure (char const* what_) : whatStr(what_)
 {}
 explicit failure (::std::string what_) : whatStr(::std::move(what_))
 {}
 ~failure () throw()
 {}
 char const* what () const throw()
 { return whatStr.c_str(); }
 failure& operator<< (char* s)
 {
 whatStr.append(s);
 return *this;
 }
 failure& operator<< (char const* s)
 {
 whatStr.append(s);
 return *this;
 }
 failure& operator<< (::std::string const& s)
 {
 whatStr.append(s);
 return *this;
 }
 template <class T>
 failure& operator<< (T const& val)
 {
 whatStr.append(::std::to_string(val));
 return *this;
 }
};
class eof : public failure {
public:
 explicit eof (char const* what_) : failure(what_)
 {}
 ~eof () throw()
 {}
 template <class T>
 eof& operator<< (T val)
 {
 failure::operator<<(val);
 return *this;
 }
};
inline void raise (failure const& ex)
{
 throw ex;
}
inline void raise (eof const& ex)
{
 throw ex;
}
}
#endif

Oo Tiib suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.

Edit 2:

Removed raise functions from above code. [1]: http://webEbenezer.net/build_integration.html

This code can be found in the archive here. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.

#ifndef CMW_ErrorWords_hh
#define CMW_ErrorWords_hh
#include <exception>
#include <string>
namespace cmw {
class failure : public ::std::exception {
 ::std::string whatStr;
public:
 explicit failure (char const* what_) : whatStr(what_)
 {}
 explicit failure (::std::string what_) : whatStr(::std::move(what_))
 {}
 ~failure () throw()
 {}
 char const* what () const throw()
 { return whatStr.c_str(); }
 failure& operator<< (char* s)
 {
 whatStr.append(s);
 return *this;
 }
 failure& operator<< (char const* s)
 {
 whatStr.append(s);
 return *this;
 }
 failure& operator<< (::std::string const& s)
 {
 whatStr.append(s);
 return *this;
 }
 template <class T>
 failure& operator<< (T const& val)
 {
 whatStr.append(::std::to_string(val));
 return *this;
 }
};
class eof : public failure {
public:
 explicit eof (char const* what_) : failure(what_)
 {}
 ~eof () throw()
 {}
 template <class T>
 eof& operator<< (T val)
 {
 failure::operator<<(val);
 return *this;
 }
};
inline void raise (failure const& ex)
{
 throw ex;
}
inline void raise (eof const& ex)
{
 throw ex;
}
}
#endif

Oo Tiib suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.

This code can be found in the [archive here][1]. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.

#ifndef CMW_ErrorWords_hh
#define CMW_ErrorWords_hh
#include <exception>
#include <string>
namespace cmw {
class failure : public ::std::exception {
 ::std::string whatStr;
public:
 explicit failure (char const* what_) : whatStr(what_)
 {}
 explicit failure (::std::string what_) : whatStr(::std::move(what_))
 {}
 ~failure () throw()
 {}
 char const* what () const throw()
 { return whatStr.c_str(); }
 failure& operator<< (char* s)
 {
 whatStr.append(s);
 return *this;
 }
 failure& operator<< (char const* s)
 {
 whatStr.append(s);
 return *this;
 }
 failure& operator<< (::std::string const& s)
 {
 whatStr.append(s);
 return *this;
 }
 template <class T>
 failure& operator<< (T const& val)
 {
 whatStr.append(::std::to_string(val));
 return *this;
 }
};
class eof : public failure {
public:
 explicit eof (char const* what_) : failure(what_)
 {}
 ~eof () throw()
 {}
 template <class T>
 eof& operator<< (T val)
 {
 failure::operator<<(val);
 return *this;
 }
};
}
#endif

Oo Tiib suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.

Edit 2:

Removed raise functions from above code. [1]: http://webEbenezer.net/build_integration.html

edited body
Source Link

SomeoneOo Tiib suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.

Someone suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.

Oo Tiib suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.

deleted 6 characters in body
Source Link
Loading
Reply to answer
Source Link
Loading
Tweeted twitter.com/#!/StackCodeReview/status/379987230292725760
Source Link
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /