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


C++ Lazy类代码示例

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


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

示例1: main

int main(int argc,char** argv) {
	cout << "Hello Lord Firal" << endl;
	int i;
	// create program state
	ProgramState* state = new ProgramState();
	state->setRunning(true);
	// read in flags
	while((i=getopt(argc,argv,"tu:")) != EOF) {
		switch(i) {
			case 'u': {
				state->setRunning(false);
				break;
			}
			case 'l': {
				// load in the parameter
				break;
			}
			default:
				break;
		}
	}
	// process flags
	// run the program
	if(state->getRunning()) {
		Lazy* program = new Lazy(state);
		program->run();
		delete program;
	}
	return 0;
}
开发者ID:ZackMisso,项目名称:ClassGenerator,代码行数:30,代码来源:main.cpp

示例2: TEST

TEST(Lazy, constUsage) {
	bool lambdaCalled = false;
	const Lazy<Foo> lazy([&lambdaCalled] { lambdaCalled = true; return Foo(42); });
	EXPECT_FALSE(lambdaCalled);
	EXPECT_FALSE(static_cast<bool>(lazy));
	EXPECT_EQ(42, (*lazy).value);
	EXPECT_EQ(42, lazy.value().value);
	EXPECT_EQ(42, lazy->value);
	EXPECT_TRUE(lambdaCalled);
	EXPECT_TRUE(static_cast<bool>(lazy));
}
开发者ID:DanielSWolf,项目名称:rhubarb-lip-sync,代码行数:11,代码来源:LazyTests.cpp

示例3: while

LLVM_ATTRIBUTE_ALWAYS_INLINE
static const Metadata *findHashableBaseTypeImpl(const Metadata *type) {
  // Check the cache first.
  if (HashableConformanceEntry *entry =
          HashableConformances->find(HashableConformanceKey{type})) {
    return entry->baseTypeThatConformsToHashable;
  }
  if (!KnownToConformToHashable &&
      !swift_conformsToProtocol(type, &_TMps8Hashable)) {
    // Don't cache the negative response because we don't invalidate
    // this cache when a new conformance is loaded dynamically.
    return nullptr;
  }
  // By this point, `type` is known to conform to `Hashable`.

  const Metadata *baseTypeThatConformsToHashable = type;
  while (true) {
    const Metadata *superclass =
        _swift_class_getSuperclass(baseTypeThatConformsToHashable);
    if (!superclass)
      break;
    if (!swift_conformsToProtocol(superclass, &_TMps8Hashable))
      break;
    baseTypeThatConformsToHashable = superclass;
  }
  HashableConformances->getOrInsert(HashableConformanceKey{type},
                                    baseTypeThatConformsToHashable);
  return baseTypeThatConformsToHashable;
}
开发者ID:KickGit,项目名称:swift,代码行数:29,代码来源:AnyHashableSupport.cpp

示例4: Render

	void Render(double time)
	{
		static const Mat4f reflection(
			Vec4f( 1.0, 0.0, 0.0, 0.0),
			Vec4f( 0.0,-1.0, 0.0, 0.0),
			Vec4f( 0.0, 0.0, 1.0, 0.0),
			Vec4f( 0.0, 0.0, 0.0, 1.0)
		);

		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			GLfloat(7.0 + SineWave(time / 12.0)*2.5),
			FullCircles(time / 10.0),
			Degrees(45.0 - SineWave(time / 7.0)*35.0)
		);

		shape_prog.Use();
		shape.Bind();

		gl.Enable(Capability::CullFace);
		gl.FrontFace(make_shape.FaceWinding());

		// render into the off-screen framebuffer
		fbo.Bind(Framebuffer::Target::Draw);
		gl.Viewport(
			(width - refl_tex_side) / 2,
			(height - refl_tex_side) / 2,
			refl_tex_side, refl_tex_side
		);
		gl.Clear().ColorBuffer().DepthBuffer();

		shape_camera_matrix.Set(
			camera *
			ModelMatrixf::Translation(0.0f, -1.0f, 0.0f) *
			reflection
		);

		gl.CullFace(Face::Front);
		shape_instr.Draw(shape_indices);

		gl.Bind(Framebuffer::Target::Draw, DefaultFramebuffer());
		gl.Viewport(width, height);
		gl.Clear().ColorBuffer().DepthBuffer();

		shape_camera_matrix.Set(camera);

		gl.CullFace(Face::Back);
		shape_instr.Draw(shape_indices);

		gl.Disable(Capability::CullFace);

		// Render the plane
		plane_prog.Use();
		plane.Bind();

		plane_camera_matrix.Set(camera);
		plane_camera_position.Set(camera.Position());

		plane_instr.Draw(plane_indices);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:60,代码来源:030_pool_tiles.cpp

示例5: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				4.5,
				Degrees(time * 35),
				Degrees(SineWave(time / 20.0) * 60)
			)
		);
		// set the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationX(FullCircles(time * 0.25))
		);

		gl.PolygonMode(PolygonMode::Line);
		gl.CullFace(Face::Front);
		torus_instr.Draw(torus_indices);
		//
		gl.PolygonMode(PolygonMode::Fill);
		gl.CullFace(Face::Back);
		torus_instr.Draw(torus_indices);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:26,代码来源:016_noise_torus.cpp

示例6: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				3.0f,
				Degrees(time * 50),
				Degrees(SineWave(time / 16.0) * 80)
			)
		);
		// the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationY(Degrees(time * 25))
		);
		// draw 36 instances of the cube
		// first the back faces
		gl.CullFace(Face::Front);
		front_facing.Set(0);
		cube_instr.Draw(cube_indices, inst_count);
		// then the front faces
		gl.CullFace(Face::Back);
		front_facing.Set(1);
		cube_instr.Draw(cube_indices, inst_count);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:26,代码来源:019_subsurf_scatter.cpp

示例7: Reshape

 void Reshape(GLuint width, GLuint height) {
     gl.Viewport(width, height);
     auto projection =
       CamMatrixf::PerspectiveX(Degrees(70), float(width) / height, 1, 200);
     sky_box_projection_matrix.Set(projection);
     shape_projection_matrix.Set(projection);
 }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:7,代码来源:023_sky.cpp

示例8: Reshape

 void Reshape(GLuint width, GLuint height) {
     gl.Viewport(width, height);
     Mat4f projection =
       CamMatrixf::PerspectiveX(Degrees(70), float(width) / height, 1, 40);
     shape_projection_matrix.Set(projection);
     plane_projection_matrix.Set(projection);
     halo_projection_matrix.Set(projection);
 }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:8,代码来源:026_shape_halo.cpp

示例9: if

const Metadata *
swift::_searchConformancesByMangledTypeName(const llvm::StringRef typeName) {
  auto &C = Conformances.get();
  const Metadata *foundMetadata = nullptr;

  pthread_mutex_lock(&C.SectionsToScanLock);

  unsigned sectionIdx = 0;
  unsigned endSectionIdx = C.SectionsToScan.size();

  for (; sectionIdx < endSectionIdx; ++sectionIdx) {
    auto &section = C.SectionsToScan[sectionIdx];
    for (const auto &record : section) {
      if (auto metadata = record.getCanonicalTypeMetadata())
        foundMetadata = _matchMetadataByMangledTypeName(typeName, metadata, nullptr);
      else if (auto pattern = record.getGenericPattern())
        foundMetadata = _matchMetadataByMangledTypeName(typeName, nullptr, pattern);

      if (foundMetadata != nullptr)
        break;
    }
    if (foundMetadata != nullptr)
      break;
  }

  pthread_mutex_unlock(&C.SectionsToScanLock);

  return foundMetadata;
}
开发者ID:adrfer,项目名称:swift,代码行数:29,代码来源:ProtocolConformance.cpp

示例10:

static const TypeContextDescriptor *
_findNominalTypeDescriptor(Demangle::NodePointer node) {
  const TypeContextDescriptor *foundNominal = nullptr;
  auto &T = TypeMetadataRecords.get();

  auto mangledName = Demangle::mangleNode(node);

  // Look for an existing entry.
  // Find the bucket for the metadata entry.
  if (auto Value = T.NominalCache.find(mangledName))
    return Value->getDescription();

  // Check type metadata records
  T.SectionsToScanLock.withLock([&] {
    foundNominal = _searchTypeMetadataRecords(T, node);
  });

  // Check protocol conformances table. Note that this has no support for
  // resolving generic types yet.
  if (!foundNominal)
    foundNominal = _searchConformancesByMangledTypeName(node);

  if (foundNominal) {
    T.NominalCache.getOrInsert(mangledName, foundNominal);
  }

  return foundNominal;
}
开发者ID:vmanot,项目名称:swift,代码行数:28,代码来源:MetadataLookup.cpp

示例11: guard

const Metadata *
swift::_searchConformancesByMangledTypeName(const llvm::StringRef typeName) {
  auto &C = Conformances.get();
  const Metadata *foundMetadata = nullptr;

  ScopedLock guard(C.SectionsToScanLock);

  unsigned sectionIdx = 0;
  unsigned endSectionIdx = C.SectionsToScan.size();

  for (; sectionIdx < endSectionIdx; ++sectionIdx) {
    auto &section = C.SectionsToScan[sectionIdx];
    for (const auto &record : section) {
      if (auto metadata = record.getCanonicalTypeMetadata())
        foundMetadata = _matchMetadataByMangledTypeName(typeName, metadata, nullptr);
      else if (auto ntd = record.getNominalTypeDescriptor())
        foundMetadata = _matchMetadataByMangledTypeName(typeName, nullptr, ntd);

      if (foundMetadata != nullptr)
        break;
    }
    if (foundMetadata != nullptr)
      break;
  }

  return foundMetadata;
}
开发者ID:007Indian,项目名称:swift,代码行数:27,代码来源:ProtocolConformance.cpp

示例12: make_pair

/// Search the witness table in the ConformanceCache. \returns a pair of the
/// WitnessTable pointer and a boolean value True if a definitive value is
/// found. \returns false if the type or its superclasses were not found in
/// the cache.
static
std::pair<const WitnessTable *, bool>
searchInConformanceCache(const Metadata *type,
                         const ProtocolDescriptor *protocol,
                         ConformanceCacheEntry *&foundEntry) {
  auto &C = Conformances.get();
  auto origType = type;

  foundEntry = nullptr;

recur_inside_cache_lock:

  // See if we have a cached conformance. Try the specific type first.

  {
    // Check if the type-protocol entry exists in the cache entry that we found.
    if (auto *Value = C.findCached(type, protocol)) {
      if (Value->isSuccessful())
        return std::make_pair(Value->getWitnessTable(), true);

      // If we're still looking up for the original type, remember that
      // we found an exact match.
      if (type == origType)
        foundEntry = Value;

      // If we got a cached negative response, check the generation number.
      if (Value->getFailureGeneration() == C.SectionsToScan.size()) {
        // We found an entry with a negative value.
        return std::make_pair(nullptr, true);
      }
    }
  }

  {
    // For generic and resilient types, nondependent conformances
    // are keyed by the nominal type descriptor rather than the
    // metadata, so try that.
    auto *description = type->getNominalTypeDescriptor().get();

    // Hash and lookup the type-protocol pair in the cache.
    if (auto *Value = C.findCached(description, protocol)) {
      if (Value->isSuccessful())
        return std::make_pair(Value->getWitnessTable(), true);

      // We don't try to cache negative responses for generic
      // patterns.
    }
  }

  // If the type is a class, try its superclass.
  if (const ClassMetadata *classType = type->getClassObject()) {
    if (classHasSuperclass(classType)) {
      type = swift_getObjCClassMetadata(classType->SuperClass);
      goto recur_inside_cache_lock;
    }
  }

  // We did not find an entry.
  return std::make_pair(nullptr, false);
}
开发者ID:007Indian,项目名称:swift,代码行数:64,代码来源:ProtocolConformance.cpp

示例13: Reshape

	void Reshape(GLuint width, GLuint height)
	{
		gl.Viewport(width, height);
		projection_matrix.Set(
			CamMatrixf::PerspectiveX(
				Degrees(70),
				width, height,
				1, 100
			)
		);
	}
开发者ID:xubingyue,项目名称:oglplus,代码行数:11,代码来源:019_bpatch_tess.cpp

示例14: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				3.5,
				Degrees(time * 35),
				Degrees(SineWave(time / 60.0) * 80)
			)
		);
		// set the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationX(FullCircles(time * 0.25))
		);

		torus_instr.Draw(torus_indices);
	}
开发者ID:xubingyue,项目名称:oglplus,代码行数:20,代码来源:016_metallic_torus.cpp

示例15: Reshape

	void Reshape(GLuint width, GLuint height)
	{
		gl.Viewport(width, height);
		prog.Use();
		projection_matrix.Set(
			CamMatrixf::PerspectiveX(
				Degrees(70),
				double(width)/height,
				1, 20
			)
		);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:12,代码来源:019_subsurf_scatter.cpp


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