当前位置: 首页>>代码示例>>C++>>正文


C++ decltype函数代码示例

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


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


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