• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ out_of_range函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中out_of_range函数的典型用法代码示例。如果您正苦于以下问题:C++ out_of_range函数的具体用法?C++ out_of_range怎么用?C++ out_of_range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了out_of_range函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: out_of_range

void denseMatrix<T>::setsize(const int size)
{
  if (size < 0)
  {
    throw out_of_range("Invalid setsize param");
  }
  m_dimentions = size;
  m_data.setsize(size);

  for (int i=0; i < size; i++)
  {
    m_data[i].setsize(size);
  }
  return;
}
开发者ID:jdbbq2,项目名称:Final-Project,代码行数:15,代码来源:densematrix.hpp


示例2: out_of_range

int wstring::compare(const wstring& str, size_t pos, size_t n) const {
    if (pos > length())
        throw out_of_range("pos > length()");
    size_t rlen = length() - pos;
    if (rlen > n)
        rlen = n;
    if (rlen > str.length())
        rlen = str.length();
    int r = wchar_traits::compare(data() + pos, str.data(), rlen);
    if (r != 0)
        return r;
    if (rlen == n)
        return 0;
    return(length() - pos) - str.length();
}
开发者ID:MagicRAR,项目名称:MagicRAR,代码行数:15,代码来源:wstring.cpp


示例3: operator

    std::pair<R, RO> operator()(T& t, R r, RO ro)
    {
        if (!r) return throw_t<_except_>( t, unexpected_end_fragment(), r );

        string_range< typename TChars::value_type > rr = srange( tchars()() );

        for ( ; rr; ++rr ) if ( *r == *rr )
            {
                if (!ro)
                    return throw_t<_except_>( t, out_of_range( tchars()(), distance(r) ), r, ro );
                *(ro++) = *rr;
                return std::make_pair(++r, ro);
            }

        return throw_t<_except_>( t, expected_of( tchars()(), distance(r) ), r, ro );
    }
开发者ID:migashko,项目名称:faslib-sandbox,代码行数:16,代码来源:ad_char_list_t.hpp


示例4: msg

CRef<IQueryFactory>
CQuerySplitter::GetQueryFactoryForChunk(Uint4 chunk_num)
{
    if (chunk_num >= m_NumChunks) {
        string msg("Invalid query chunk number: ");
        msg += NStr::IntToString(chunk_num) + " out of " +
            NStr::IntToString(m_NumChunks);
        throw out_of_range(msg);
    }

    if (m_SplitBlk.Empty()) {
        Split();
    }

    return m_QueryChunkFactories[chunk_num];
}
开发者ID:jackgopack4,项目名称:pico-blast,代码行数:16,代码来源:split_query_cxx.cpp


示例5: _copy

  std::pair<R, RO> _copy(T& t, R r, RR rr, RO ro)
  {
    for ( ;r && rr && ro && *r==*rr; ++r, ++rr)
      *(ro++) = *r;
    
    if (rr && !r)
      return throw_t<_except_>( t, unexpected_end_fragment(), r, ro );

    if (rr && !ro)
      return throw_t<_except_>( t, out_of_range( distance(r) ), r, ro );

    if (rr)
      return throw_t<_except_>( t, expected_of( typename string_list::left_type()(), distance(r) ), r, ro);
    
    return std::make_pair(r, ro);
  }
开发者ID:migashko,项目名称:faslib-sandbox,代码行数:16,代码来源:ad_cstring_list_t.hpp


示例6: check_range

    /**
     * Check if specified index is within range.
     *
     * This check is 1-indexed by default. This behavior can be
     * changed by setting <code>stan::error_index::value</code>.
     *
     * @param function Function name (for error messages)
     * @param name Variable name (for error messages)
     * @param max Maximum size of the variable
     * @param index Index to check
     * @param nested_level Nested level (for error messages)
     * @param error_msg Additional error message (for error messages)
     *
     * @throw <code>std::out_of_range</code> if the index is not in range
     */
    inline void check_range(const char* function,
                            const char* name,
                            int max,
                            int index,
                            int nested_level,
                            const char* error_msg) {
      if ((index >= stan::error_index::value)
          && (index < max + stan::error_index::value))
        return;

      std::stringstream msg;
      msg << "; index position = " << nested_level;
      std::string msg_str(msg.str());

      out_of_range(function, max, index, msg_str.c_str(), error_msg);
    }
开发者ID:stan-dev,项目名称:math,代码行数:31,代码来源:check_range.hpp


示例7: findBook

//removes next person from queue
void BookTracker::sellBook(string bookNameIn) {
    try {
        BookNode *node = findBook(bookNameIn);
        WaitList *list = node->getList();
        //if the list is not empty
        if (list->peek() != nullptr) {
            throw out_of_range("There are people waiting for this book. ");
        }
        node->addToHaveValue(-1);
    } catch (invalid_argument e) {
        //rethrow error
        throw e;
    } catch (out_of_range x) {
        //rethrow error
        throw x;
    }
}
开发者ID:kuntajts,项目名称:Library,代码行数:18,代码来源:BookTracker.cpp


示例8: out_of_range

bool repository::extractor::need_update(
    const boost::filesystem::path &destination, const std::time_t lifetime) {
  try {
    BUNSAN_LOG_DEBUG << "Starting " << destination << " " << __func__;
    const boost::filesystem::path meta =
        destination / m_config.installation.meta;
    return !boost::filesystem::is_regular_file(meta) ||
           out_of_range(std::time(nullptr), lifetime,
                        boost::filesystem::last_write_time(meta));
  } catch (std::exception &) {
    BOOST_THROW_EXCEPTION(
        extractor_need_update_error()
        << extractor_need_update_error::destination(destination)
        << extractor_need_update_error::lifetime(lifetime)
        << enable_nested_current());
  }
}
开发者ID:bunsanorg,项目名称:pm,代码行数:17,代码来源:extractor.cpp


示例9: check_row_index

    inline bool check_row_index(const char* function,
                                const char* name,
                                const Eigen::Matrix<T_y, R, C>& y,
                                size_t i) {
      if (i >= stan::error_index::value
          && i < static_cast<size_t>(y.rows()) + stan::error_index::value)
        return true;

      std::stringstream msg;
      msg << " for rows of " << name;
      std::string msg_str(msg.str());
      out_of_range(function,
                   y.rows(),
                   i,
                   msg_str.c_str());
      return false;
    }
开发者ID:javaosos,项目名称:stan,代码行数:17,代码来源:check_row_index.hpp


示例10: stoull

unsigned long long
stoull(const wstring& str, size_t* idx, int base)
{
    wchar_t* ptr;
    const wchar_t* const p = str.c_str();
    unsigned long long r = wcstoull(p, &ptr, base);
    if (ptr == p)
    {
#ifndef _LIBCPP_NO_EXCEPTIONS
        if (r == 0)
            throw invalid_argument("stoull: no conversion");
        throw out_of_range("stoull: out of range");
#endif  // _LIBCPP_NO_EXCEPTIONS
    }
    if (idx)
        *idx = static_cast<size_t>(ptr - p);
    return r;
}
开发者ID:themiwi,项目名称:libcxx,代码行数:18,代码来源:string.cpp


示例11: stold

long double
stold(const string& str, size_t* idx)
{
    char* ptr;
    const char* const p = str.c_str();
    typename remove_reference<decltype(errno)>::type errno_save = errno;
    errno = 0;
    long double r = strtold(p, &ptr);
    swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
    if (errno_save == ERANGE)
        throw out_of_range("stold: out of range");
    if (ptr == p)
        throw invalid_argument("stold: no conversion");
#endif  // _LIBCPP_NO_EXCEPTIONS
    if (idx)
        *idx = static_cast<size_t>(ptr - p);
    return r;
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:19,代码来源:string.cpp


示例12: stol

long
stol(const wstring& str, size_t* idx, int base)
{
    wchar_t* ptr;
    const wchar_t* const p = str.c_str();
    typename remove_reference<decltype(errno)>::type errno_save = errno;
    errno = 0;
    long r = wcstol(p, &ptr, base);
    swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
    if (errno_save == ERANGE)
        throw out_of_range("stol: out of range");
    if (ptr == p)
        throw invalid_argument("stol: no conversion");
#endif  // _LIBCPP_NO_EXCEPTIONS
    if (idx)
        *idx = static_cast<size_t>(ptr - p);
    return r;
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:19,代码来源:string.cpp


示例13: pythonAddEdge

// addedge(x1, y1, x2, y2, angle = 0, marker = "none")
void pythonAddEdge(double x1, double y1, double x2, double y2, double angle, char *marker)
{
    logMessage("pythonAddEdge()");

    if (angle > 90.0 || angle < 0.0)
        throw out_of_range(QObject::tr("Angle '%1' is out of range.").arg(angle).toStdString());

    SceneBoundary *boundary = Util::scene()->getBoundary(QString(marker));
    if (!boundary)
        throw invalid_argument(QObject::tr("Boundary '%1' is not defined.").arg(marker).toStdString());

    // start node
    SceneNode *nodeStart = Util::scene()->addNode(new SceneNode(Point(x1, y1)));
    // end node
    SceneNode *nodeEnd = Util::scene()->addNode(new SceneNode(Point(x2, y2)));

    // FIXME 0 -> variable
    Util::scene()->addEdge(new SceneEdge(nodeStart, nodeEnd, boundary, angle, 0));
}
开发者ID:honzakac,项目名称:agros2d,代码行数:20,代码来源:pythonlabagros.cpp


示例14: operator

  RR operator()(T& t, RR rr)
  {
    for (register int i=0; i < 4; ++i)
    {
      if ( !this->peek(t, rr.first) )
      {
        if (rr.first)
          return throw_<_except_>( t, parse_error( distance(rr.first) ), rr);
        else
          return throw_<_except_>( t, unexpected_end_fragment(), rr);
      }

      if ( !rr.second )
        return throw_<_except_>( t, out_of_range( distance(rr.first) ), rr );

      *(rr.second++)= *(rr.first++);
    }
    return rr;
  }
开发者ID:migashko,项目名称:faslib-sandbox,代码行数:19,代码来源:ad_four_hex_digits.hpp


示例15: stof

float
stof(const string& str, size_t* idx)
{
    char* ptr;
    const char* const p = str.c_str();
    int errno_save = errno;
    errno = 0;
    double r = strtod(p, &ptr);
    swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
    if (errno_save == ERANGE)
        throw out_of_range("stof: out of range");
    if (ptr == p)
        throw invalid_argument("stof: no conversion");
#endif  // _LIBCPP_NO_EXCEPTIONS
    if (idx)
        *idx = static_cast<size_t>(ptr - p);
    return static_cast<float>(r);
}
开发者ID:themiwi,项目名称:libcxx,代码行数:19,代码来源:string.cpp


示例16: stold

long double
stold(const wstring& str, size_t* idx)
{
    wchar_t* ptr;
    const wchar_t* const p = str.c_str();
    int errno_save = errno;
    errno = 0;
    long double r = wcstold(p, &ptr);
    swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
    if (errno_save == ERANGE)
        throw out_of_range("stold: out of range");
    if (ptr == p)
        throw invalid_argument("stold: no conversion");
#endif  // _LIBCPP_NO_EXCEPTIONS
    if (idx)
        *idx = static_cast<size_t>(ptr - p);
    return r;
}
开发者ID:themiwi,项目名称:libcxx,代码行数:19,代码来源:string.cpp


示例17: operator

  RR operator()(T& t, RR rr)
  {
    tstring_range sr = tstring_range( tstring()() );
    for (;sr;++sr)
    {
      if (!rr.second)
        return throw_<_except_>( t, out_of_range( distance(rr.first) ), rr );

      if ( !rr.first )
        return throw_<_except_>( t, unexpected_end_fragment(), rr );

      if ( *rr.first != *sr )
        return throw_<_except_>( t, expected_of(tstring()(),  distance(rr.first) ), rr );

      *(rr.second++) = *(rr.first++);
    }

    return rr;
  }
开发者ID:migashko,项目名称:faslib-sandbox,代码行数:19,代码来源:ad_tstring.hpp


示例18: if

	token lexer::parse_number(location_ptr &start, const string &value) {
		string unprefixedValue;

		uint8_t base = 10;
		if (istarts_with(value, "0x")) {
			base = 16;
			unprefixedValue = value.substr(2);
		} else if (istarts_with(value, "0o")) {
			base = 8;
			unprefixedValue = value.substr(2);
		} else if (istarts_with(value, "0b")) {
			base = 2;
			unprefixedValue = value.substr(2);
		} else {
			unprefixedValue = value;
		}

		// prefix without an actual value
		if (unprefixedValue.length() == 0) {
			return token(start, token_type::INVALID_INTEGER, value);
		}

		size_t pos;
		try {
			unsigned long parsed_value = stoul(unprefixedValue, &pos, base);
			if (pos != unprefixedValue.size()) {
				return token(start, token_type::INVALID_INTEGER, value);
			}

			if (parsed_value > numeric_limits<uint32_t>::max()) {
				throw out_of_range(value);
			}

			return token(start, token_type::INTEGER, value, (uint32_t)parsed_value);
		} catch (invalid_argument &ia) {
			return token(start, token_type::INVALID_INTEGER, value);
		} catch (out_of_range &oor) {
			logger.warning(start, format("overflow converting '%s' to a 32-bit integer") % value);

			return token(start, token_type::INTEGER, value, numeric_limits<uint32_t>::max());
		}
	}
开发者ID:storance,项目名称:dcpu16,代码行数:42,代码来源:lexer.cpp


示例19: stoi

int
stoi(const string& str, size_t* idx, int base)
{
    char* ptr;
    const char* const p = str.c_str();
    typename remove_reference<decltype(errno)>::type errno_save = errno;
    errno = 0;
    long r = strtol(p, &ptr, base);
    swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
    if (errno_save == ERANGE || r < numeric_limits<int>::min() ||
                                numeric_limits<int>::max() < r)
        throw out_of_range("stoi: out of range");
    if (ptr == p)
        throw invalid_argument("stoi: no conversion");
#endif  // _LIBCPP_NO_EXCEPTIONS
    if (idx)
        *idx = static_cast<size_t>(ptr - p);
    return static_cast<int>(r);
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:20,代码来源:string.cpp


示例20: out_of_range

void Candidate::init_can(int numvar, /*!<number of variables*/
                         int fit_size /*!< the number of objective functions*/
                        ) {
    if(numvar <= 0) {
        throw out_of_range("numvar must be positive.");
        }
    if(fit_size <= 0) {
        throw invalid_argument("num_fit must be positive.");
        }
    num = numvar;
    can_best = new double[num];
    contender = new double[num];
    global_best = new double[num];

    num_fit = fit_size;
    best_fit = new double[num_fit];
    cont_fit = new double[num_fit];
    global_fit = new double[num_fit];
    is_candidate_initialized = true;
    }
开发者ID:PanPalitta,项目名称:phase_estimation,代码行数:20,代码来源:candidate.cpp



注:本文中的out_of_range函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ out_uint16_le函数代码示例发布时间:2022-05-30
下一篇:
C++ out_nl函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap