<commit_before>#ifndef STAN__LANG__LINE_NUM_EXCEPTION_HPP
#define STAN__LANG__LINE_NUM_EXCEPTION_HPP

#include <exception>
#include <iostream>
#include <new>
#include <sstream>
#include <stdexcept>
#include <string>
#include <typeinfo>

namespace stan {
  
  namespace lang {

    /**
     * Class to hold a reference to a nested exception along with a
     * starting line number of the statement in the Stan program which
     * caused the exception.
     *
     * <p>The exception class is defined to extend the type of the
     * of the nested exception so that catch statements cn be
     * keyed to the original exception type (or the templated line
     * number exception type).
     *
     * @tparam E Type of nested exception.
     */
    template <class E>
    class located_exception : public E { 

    private:

      /** Nested exception. */
      const E& e_;

      /** Line number where exception arose or -1 if unknown. */
      const int line_;

      /** Message describing exception */
      const std::string what_;
      
      /**
       * Construct the message for the exception description.
       * 
       * <p>This is a nested static function so that the constructor
       * can create the message and assign it to a constant member
       * variable. 
       *
       * @param e The nested exception.
       * @param line Line number of exception or -1 if unkown.
       * @return Description of exception including original
       * description and line number.
       */
      static std::string construct_what(const E& e, int line) throw() {
        std::ostringstream o;
        o << "Exception raised at line="
          << line
          << ": "
          << e.what();
        return o.str();
      }


    public:

      /**
       * Construct a located exception from a reference to the nested
       * exception and line number in a Stan program where the
       * exception arose.
       *
       * @param e Nested exception reference.
       * @param line Line number of statement where exception arose,
       * or -1 if it is unknown.
       */
      located_exception(const E& e, int line) throw()
        : E(e),
          e_(e),
          line_(line),
          what_(std::string("exception raised at line=")
                + std::to_string(line)
                + std::string(": ")
                + std::string(e.what())) {
      }

      /**
       * Destroy this exception.  Because the nested exception is a
       * reference, it is not destroyed.
       */
      ~located_exception() throw() { }

      /**
       * Return a description of the exception, which includes the
       * line number and the description of the nested exception.
       *
       * @return Description of exception.
       */
      const char* what() const throw() {
        return what_.c_str();
      };<commit_msg>removed C++11 dependency for located exception<commit_after>#ifndef STAN__LANG__LINE_NUM_EXCEPTION_HPP
#define STAN__LANG__LINE_NUM_EXCEPTION_HPP

#include <exception>
#include <iostream>
#include <new>
#include <sstream>
#include <stdexcept>
#include <string>
#include <typeinfo>

namespace stan {
  
  namespace lang {

    /**
     * Class to hold a reference to a nested exception along with a
     * starting line number of the statement in the Stan program which
     * caused the exception.
     *
     * <p>The exception class is defined to extend the type of the
     * of the nested exception so that catch statements cn be
     * keyed to the original exception type (or the templated line
     * number exception type).
     *
     * @tparam E Type of nested exception.
     */
    template <class E>
    class located_exception : public E { 

    private:

      /** Nested exception. */
      const E& e_;

      /** Line number where exception arose or -1 if unknown. */
      const int line_;

      /** Message describing exception */
      const std::string what_;
      
      /**
       * Construct the message for the exception description.
       * 
       * <p>This is a nested static function so that the constructor
       * can create the message and assign it to a constant member
       * variable. 
       *
       * @param e The nested exception.
       * @param line Line number of exception or -1 if unkown.
       * @return Description of exception including original
       * description and line number.
       */
      static std::string construct_what(const E& e, int line) throw() {
        std::ostringstream o;
        o << "Exception raised at line="
          << line
          << ": "
          << e.what();
        return o.str();
      }


    public:

      /**
       * Construct a located exception from a reference to the nested
       * exception and line number in a Stan program where the
       * exception arose.
       *
       * @param e Nested exception reference.
       * @param line Line number of statement where exception arose,
       * or -1 if it is unknown.
       */
      located_exception(const E& e, int line) throw()
        : E(e),
          e_(e),
          line_(line),
          what_(construct_what(e,line)) {
      }

      /**
       * Destroy this exception.  Because the nested exception is a
       * reference, it is not destroyed.
       */
      ~located_exception() throw() { }

      /**
       * Return a description of the exception, which includes the
       * line number and the description of the nested exception.
       *
       * @return Description of exception.
       */
      const char* what() const throw() {
        return what_.c_str();
      };
{'fraction_non_alphanumeric': 0.08559685489635453, 'fraction_numerical': 0.0014295925661186562, 'mean_word_length': 2.03360433604336, 'pattern_counts': {'":': 3, '<': 39, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1540417', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1441, 'n_words': 591}