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

C++ decltype函数代码示例

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

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



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

示例1: main

int main()
{
    std::multimap<std::string, std::string> m{{"Hello", "World"}, {"Bye", "World"}, {"Foo", "Bar"}};
    std::vector<decltype(m)::value_type> vec;
    
    std::copy_if(m.begin(), m.end(), std::back_inserter(vec),
        [](decltype(m)::value_type const& kv) {
            return std::any_of(kv.first.begin(), kv.first.end(), 
                               [](std::string::value_type c) { return c == 'e'; });
        });
    
    for(auto const& v : vec) {
        std::cout << v.first << ": " << v.second << std::endl;
    }
}
开发者ID:CCJY,项目名称:coliru,代码行数:15,代码来源:main.cpp


示例2: decltype

	void Manager::unloadUnused()
	{
		std::vector< decltype( resources )::iterator > unload;
		for ( auto it = resources.begin(); it != resources.end(); ++it )
		{
			if ( it->second->refs == 0 )
			{
				unload.push_back( it );
			}
		}
		
		for ( auto it = unload.begin(); it != unload.end(); ++it )
		{
			resources.erase( * it );
		}
	}
开发者ID:spacechase0,项目名称:Game-Base,代码行数:16,代码来源:Manager.cpp


示例3: initialize_tls

	static never_inline void initialize_tls()
	{
		// allocate if not initialized
		if (!g_tls_net_data)
		{
			g_tls_net_data.set(vm::alloc(sizeof(decltype(g_tls_net_data)::type), vm::main));
			
			// Initial values
			g_tls_net_data->_errno = SYS_NET_EBUSY;

			thread_ctrl::atexit([addr = g_tls_net_data.addr()]
			{
				vm::dealloc_verbose_nothrow(addr, vm::main);
			});
		}
	}
开发者ID:Pyroapple,项目名称:rpcs3,代码行数:16,代码来源:sys_net.cpp


示例4: FromSerialized

Dictionnary Dictionnary::FromSerialized(std::istream& in) {
    Dictionnary dict;
    size_t nb;
    in >> nb;

    std::string w;
    size_t id;
    dict.stats_.resize(nb);
    for (size_t i = 0; i < nb; ++i) {
        in >> w >> id;
        in >> dict.stats_[id];
        dict.dict_.insert(decltype (dict.dict_)::value_type(w, id));
    }

    return dict;
}
开发者ID:Vermeille,项目名称:nlp-common,代码行数:16,代码来源:dict.cpp


示例5: checkBreakActions

void Reports::checkBreakActions(const Experiment &experiment,
                                const std::vector<Report::Event> &events) {
    auto available = std::unordered_set<std::int32_t>{};
    for (const auto &action : experiment.breakActions) {
        available.insert(action.ID);
    }

    for (const auto &event : events) {
        if (!event.exhibitID) {
            if (!utils::all_of(event.actions,
                               std::bind(&decltype(available)::count, &available, _1))) {
                throw InvalidData{"incorrect break action ID"};
            }
        }
    }
}
开发者ID:majeski,项目名称:NUBZ,代码行数:16,代码来源:Reports.cpp


示例6: m_path

Torrent::Torrent(string path) :
	m_path(path)
{
	m_torrent_params.save_path = "./";
	if (gt::Core::isMagnetLink(path))
	{
		m_torrent_params.url = path;
	}
	else
	{
			//libtorrent::add_torrent_params.ti is an intrusive_ptr in 1.0 and a shared_ptr in svn.
			//Using decltype allows us to make it compatible with both versions while still properly using the constructor to avoid a compiler error on boost 1.55 when the = operator is used with a pointer.
			m_torrent_params.ti = decltype(m_torrent_params.ti)(new libtorrent::torrent_info(path)); 
	}

}
开发者ID:truNEET,项目名称:gTorrent,代码行数:16,代码来源:Torrent.cpp


示例7: decltype

const IrisValue & IrisModule::GetCurrentModuleConstance(const string& strConstanceName, bool& bResult)
{
	decltype(m_hsConstances)::iterator iVariable;
	m_iwlModuleConstanceWLLock.ReadLock();
	if ((iVariable = m_hsConstances.find(strConstanceName)) != m_hsConstances.end()) {
		auto& ivResult = iVariable->second;
		bResult = true;
		m_iwlModuleConstanceWLLock.ReadUnlock();
		return ivResult;
	}
	else {
		m_iwlModuleConstanceWLLock.ReadUnlock();
		bResult = false;
		return IrisDevUtil::Nil();
	}
}
开发者ID:RedFog,项目名称:Iris-Language,代码行数:16,代码来源:IrisModule.cpp


示例8: block

void Sz4BlockTestCase::weigthedSumTest2() {
	typedef sz4::value_time_pair<short, sz4::second_time_t> pair_type;
	std::vector<pair_type> v;
	sz4::concrete_block<short, unsigned> block(0u, &m_cache);
	sz4::weighted_sum<short, sz4::second_time_t> wsum;
	sz4::weighted_sum<short, sz4::second_time_t>::time_diff_type weight;

	v.push_back(sz4::make_value_time_pair<pair_type>((short)1, 1u));
	v.push_back(sz4::make_value_time_pair<pair_type>(std::numeric_limits<short>::min(), 2u));
	v.push_back(sz4::make_value_time_pair<pair_type>((short)1, 3u));
	block.set_data(v);

	block.get_weighted_sum(0u, 3u, wsum);
	CPPUNIT_ASSERT_EQUAL(decltype(wsum)::sum_type(2), wsum.sum(weight));
	CPPUNIT_ASSERT_EQUAL(2l, weight);
}
开发者ID:Strongc,项目名称:szarp,代码行数:16,代码来源:sz4_block_unit_test.cpp


示例9: erase_values

/// Erase from a list of wcstring values at specified indexes.
static void erase_values(wcstring_list_t &list, const std::vector<long> &indexes) {
    // Make a set of indexes.
    // This both sorts them into ascending order and removes duplicates.
    const std::set<long> indexes_set(indexes.begin(), indexes.end());

    // Now walk the set backwards, so we encounter larger indexes first, and remove elements at the
    // given (1-based) indexes.
    decltype(indexes_set)::const_reverse_iterator iter;
    for (iter = indexes_set.rbegin(); iter != indexes_set.rend(); ++iter) {
        long val = *iter;
        if (val > 0 && (size_t)val <= list.size()) {
            // One-based indexing!
            list.erase(list.begin() + val - 1);
        }
    }
}
开发者ID:kballard,项目名称:fish-shell,代码行数:17,代码来源:builtin_set.cpp


示例10: m_renderWindowInteractor

silly_renderer::silly_renderer()
  : m_renderWindowInteractor(decltype(m_renderWindowInteractor)::New())
{
  // Create a sphere
  vtkSmartPointer<vtkSphereSource> sphereSource =
    vtkSmartPointer<vtkSphereSource>::New();
  sphereSource->Update();

  vtkSmartPointer<vtkProgrammableFilter> programmableFilter =
    vtkSmartPointer<vtkProgrammableFilter>::New();
  programmableFilter->SetInputConnection(sphereSource->GetOutputPort());
  programmableFilter->SetExecuteMethod(AdjustPoints, programmableFilter);

  // Create a mapper and actor
  vtkSmartPointer<vtkPolyDataMapper> mapper =
    vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(programmableFilter->GetOutputPort());
  vtkSmartPointer<vtkActor> actor =
    vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);

  // Create a renderer, render window, and interactor
  vtkSmartPointer<vtkRenderer> renderer =
    vtkSmartPointer<vtkRenderer>::New();
  vtkSmartPointer<vtkRenderWindow> renderWindow =
    vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);

  m_renderWindowInteractor->SetRenderWindow(renderWindow);

  // Initialize must be called prior to creating timer events.
  m_renderWindowInteractor->Initialize();
  m_renderWindowInteractor->CreateRepeatingTimer(500);

  vtkSmartPointer<CommandSubclass> timerCallback =
    vtkSmartPointer<CommandSubclass>::New();
  timerCallback->ProgrammableFilter = programmableFilter;

  m_renderWindowInteractor->AddObserver ( vtkCommand::TimerEvent, timerCallback );

  // Add the actor to the scene
  renderer->AddActor(actor);
  renderer->SetBackground(1,1,1); // Background color white

  // Render
  renderWindow->Render();
}
开发者ID:mmmaat,项目名称:cochleo,代码行数:47,代码来源:silly_renderer.cpp


示例11: setupSysEnd

void setupSysEnd() {
    std::vector<Box*> builtin_module_names;
    for (int i = 0; PyImport_Inittab[i].name != NULL; i++)
        builtin_module_names.push_back(boxString(PyImport_Inittab[i].name));

    std::sort<decltype(builtin_module_names)::iterator, PyLt>(builtin_module_names.begin(), builtin_module_names.end(),
                                                              PyLt());

    sys_module->giveAttr("builtin_module_names",
                         BoxedTuple::create(builtin_module_names.size(), &builtin_module_names[0]));

    for (Box* b : builtin_module_names)
        Py_DECREF(b);

#ifndef NDEBUG
    for (const auto& p : *sys_modules_dict) {
        assert(PyString_Check(p.first));

        bool found = false;
        for (int i = 0; PyImport_Inittab[i].name != NULL; i++) {
            if (((BoxedString*)p.first)->s() == PyImport_Inittab[i].name) {
                found = true;
            }
        }
        if (!found)
            assert(0 && "found a module which is inside sys.modules but not listed inside PyImport_Inittab!");
    }
#endif

    /* version_info */
    if (VersionInfoType.tp_name == 0)
        PyStructSequence_InitType((PyTypeObject*)&VersionInfoType, &version_info_desc);
    /* prevent user from creating new instances */
    VersionInfoType.tp_init = NULL;
    VersionInfoType.tp_new = NULL;

    SET_SYS_FROM_STRING("version_info", make_version_info());

    /* float_info */
    if (FloatInfoType.tp_name == 0)
        PyStructSequence_InitType((PyTypeObject*)&FloatInfoType, &float_info_desc);
    /* prevent user from creating new instances */
    FloatInfoType.tp_init = NULL;
    FloatInfoType.tp_new = NULL;

    SET_SYS_FROM_STRING("float_info", PyFloat_GetInfo());
}
开发者ID:Thooms,项目名称:pyston,代码行数:47,代码来源:sys.cpp


示例12: extract

static tuple<
        unique_ptr<AnimObj::Geom::nds_vt>,
        unique_ptr<AnimObj::Geom::NormalData::NsV>,
        unique_ptr<AnimObj::Geom::nds_vt>> extract(AnimObj::Geom::NormalData::NsV const& ons)
{
    std::vector<std::array<float, 3>> nrmf;
    Alembic::AbcGeom::N3fArraySample::value_vector::size_type const nsz = ons.size();
    nrmf.reserve(nsz);
    for (size_t k = 0; k < nsz; ++k)
    {
        Alembic::AbcGeom::N3fArraySample::value_type const& v = ons[k];
        decltype(nrmf)::value_type a = {v[0], v[1], v[2]};
        nrmf.emplace_back(a);
    }
    decltype(nrmf) nrms(nrmf);
    std::sort(nrms.begin(), nrms.end());
    std::size_t const d = std::distance(nrms.begin(), std::unique(nrms.begin(), nrms.end()));
    Alembic::AbcGeom::N3fArraySample::value_vector nsv(d);
    std::vector<std::pair<decltype(nrmf)::value_type, int>> nrmN;
    for (size_t m = 0; m < d; ++m)
    {
        decltype(nrms)::value_type const& n = nrms[m];
        nrmN.emplace_back(n, m);
        nsv[m] = {n[0], n[1], n[2]};
    }
    Alembic::AbcGeom::UInt32ArraySample::value_vector ndxv(nsz);
    Alembic::AbcGeom::UInt32ArraySample::value_vector ndrxv(d);
    decltype(nrmN)::const_iterator const& nrmNB = nrmN.cbegin();
    decltype(nrmN)::const_iterator const& nrmNE = nrmN.cend();
    for (size_t m = 0; m < nsz; ++m)
    {
        decltype(nrmN)::const_iterator const& found = std::lower_bound(
                nrmNB, nrmNE, nrmf[m],
                [](decltype(nrmN)::value_type const& a, decltype(nrmf)::value_type const& b)
                { return a.first < b; } );
        if (nrmNE == found)
        {
            continue;
        }
        ndrxv[std::distance(nrmNB, found)] = m;
        ndxv[m] = found->second;
    }
    return std::make_tuple(
            std::make_unique<AnimObj::Geom::nds_vt>(ndxv),
            std::make_unique<AnimObj::Geom::NormalData::NsV>(nsv),
            std::make_unique<AnimObj::Geom::nds_vt>(ndrxv));
}
开发者ID:axisanimation,项目名称:alembic,代码行数:47,代码来源:levOpt2.cpp


示例13: main

int main(int argc, const char* argv[])
{
    std::string s1 = "abcd<ht";
    std::string s2 = "ml>giuya";
    
    boost::iterator_range<std::string::iterator> ir1 = boost::make_iterator_range(s1);
    boost::iterator_range<std::string::iterator> ir2 = boost::make_iterator_range(s2);
    auto ir3 = boost::join(ir1,ir2);
    
    boost::regex e("<[^>]*>");
    boost::match_results<decltype(ir3)::iterator> what;
    
    boost::regex_search(ir3.begin(), ir3.end(), what, e, 
                        boost::match_default | boost::match_partial);
    std::cout << std::string(what[0].first, what[0].second) << std::endl;
    //std::cout << what[0].second << std::endl;
}
开发者ID:CCJY,项目名称:coliru,代码行数:17,代码来源:main.cpp


示例14: precomputeGrainStructure

void
PolycrystalUserObjectBase::execute()
{
  if (!_colors_assigned)
    precomputeGrainStructure();
  // No need to rerun the object if the mesh hasn't changed
  else if (!_fe_problem.hasInitialAdaptivity())
    return;

  /**
   * We need one map per grain when creating the initial condition to support overlapping features.
   * Luckily, this is a fairly sparse structure.
   */
  _entities_visited.resize(getNumGrains());

  /**
   * This loop is similar to the one found in the base class however, there are two key differences
   * between building up the initial condition and discovering features based on solution variables:
   *
   * 1) When building up the initial condition, we aren't inspecting the actual variable values so
   *    we don't need to loop over all of the coupled variables.
   * 2) We want to discover all features on a single pass since there may be thousands of features
   *    in a simulation. However, we can only actively flood a single feature at a time. To make
   *    sure that we pick up all features that might start on a given entity, we'll keep retrying
   *    the flood routine on the same entity as long as new discoveries are being made. We know
   *    this information from the return value of flood.
   */
  for (const auto & current_elem : _mesh.getMesh().active_local_element_ptr_range())
  {
    // Loop over elements or nodes
    if (_is_elemental)
      while (flood(current_elem, invalid_size_t, nullptr))
        ;
    else
    {
      auto n_nodes = current_elem->n_vertices();
      for (auto i = decltype(n_nodes)(0); i < n_nodes; ++i)
      {
        const Node * current_node = current_elem->get_node(i);

        while (flood(current_node, invalid_size_t, nullptr))
          ;
      }
    }
  }
}
开发者ID:huangh-inl,项目名称:moose,代码行数:46,代码来源:PolycrystalUserObjectBase.C


示例15: main

int main() {
  Solution sol;
  string serialized_tree("5 4 11 7 # # 2 # # # 8 13 # # 4 5 # # 1 4 # # #");
  TreeNode *root = deserialize_tree(serialized_tree);
  preorder_cout(root);
  int sum = 22;
  // auto result = sol.pathSum(root, sum);
  // auto result = sol.pathSum(NULL, 0);
  // auto result = sol.pathSum(root->right->left, 13);
  auto result = sol.pathSum(root->right->right, 9);
  for (auto row: result) {
    copy(row.begin(), row.end(), 
      ostream_iterator<decltype(row)::value_type>(cout, " "));
    cout << '\n';
  }
  return 0;
}
开发者ID:HustLion,项目名称:algorithm,代码行数:17,代码来源:path-sum-ii.cpp


示例16: window

CMT_NOINLINE expression_pointer<T> window(size_t size, window_type type, identity<T> win_param,
                                          window_symmetry symmetry = window_symmetry::symmetric,
                                          ctype_t<T>               = ctype_t<T>())
{
    return cswitch(
        cvals_t<window_type, window_type::rectangular, window_type::triangular, window_type::bartlett,
                window_type::cosine, window_type::hann, window_type::bartlett_hann, window_type::hamming,
                window_type::bohman, window_type::blackman, window_type::blackman_harris, window_type::kaiser,
                window_type::flattop, window_type::gaussian, window_type::lanczos>(),
        type,
        [size, win_param, symmetry](auto win) {
            constexpr window_type window = val_of(decltype(win)());
            return to_pointer(
                typename internal::window_by_type<window>::template type<T>(size, win_param, symmetry));
        },
        fn_generic::returns<expression_pointer<T>>());
}
开发者ID:kfrlib,项目名称:kfr,代码行数:17,代码来源:window.hpp


示例17: seqVectorToPy

	static py::object seqVectorToPy(const IteratorRange& range, ItemGetter itemGetter, bool zipped){
		if(!zipped){
			size_t num=decltype(itemGetter(*(range.begin())))::RowsAtCompileTime;
			vector<py::list> ret(num);
			for(const auto& p: range){
				auto item=itemGetter(p);
				for(int i=0; i<item.size(); i++) ret[i].append(item[i]);
			}
			py::list l;
			for(size_t i=0; i<ret.size(); i++) l.append(ret[i]);
			return py::tuple(l);
		} else {
			py::list ret;
			for(const auto& p: range){ ret.append(itemGetter(p)); }
			return ret;
		}
	}
开发者ID:CrazyHeex,项目名称:woo,代码行数:17,代码来源:Funcs.hpp


示例18: decltype

PropertyDataType ExponentialProperty::d2Value(
    VariableArray const& variable_array,
    Variable const pv1,
    Variable const pv2) const
{
    return _exponent_data.type == pv1 && _exponent_data.type == pv2
               ? boost::get<double>(_value) *
                     boost::math::pow<2>(
                         boost::get<double>(_exponent_data.factor)) *
                     std::exp(
                         -boost::get<double>(_exponent_data.factor) *
                         (boost::get<double>(variable_array[static_cast<int>(
                              _exponent_data.type)]) -
                          boost::get<double>(
                              _exponent_data.reference_condition)))
               : decltype(_value){};
}
开发者ID:TomFischer,项目名称:ogs,代码行数:17,代码来源:ExponentialProperty.cpp


示例19: operator

 constexpr auto operator()(Def) const
 {
   constexpr auto children = hana::second(Def{});
   constexpr auto single_provider = hana::transform(hana::find(children, tag::Provider),
       hana::partial(mpdef::make_tree_node, tag::Provider));
   constexpr auto providers = hana::find(children, tag::Providers);
   static_assert(hana::value(
     ((single_provider == hana::nothing) || (providers == hana::nothing))
     && hana::not_(single_provider == hana::nothing && providers == hana::nothing)
   ), "A definition of a Provider or Providers is required.");
   return decltype(
     helper(providers.value_or(
         hana::maybe(mpdef::make_list(), mpdef::make_list, single_provider)
       )
     )
   ){};
 }
开发者ID:ricejasonf,项目名称:nbdl,代码行数:17,代码来源:enumerate_providers.hpp


示例20: file

File::Buffer File::read(const std::string& fileName)
{
	std::ifstream file(fileName.c_str(),
	                   std::ios::in | std::ios::binary | std::ios::ate);

	if (!file.is_open())
		throw std::runtime_error("Unable to open file: " + fileName);

	Buffer buf;
	buf.fileName = fileName;
	buf.data = decltype(Buffer::data)(file.tellg());

	file.seekg(0, std::ios::beg);
	file.read(&buf.data[0], buf.data.size());

	return buf;
}
开发者ID:lonnibesancon,项目名称:FluidAppAndroid,代码行数:17,代码来源:file.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ decode函数代码示例发布时间:2022-05-30
下一篇:
C++ declareProperty函数代码示例发布时间: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