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


C++ S类代码示例

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


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

示例1: main

int
main ()
{
  constexpr S a {};
  constexpr int i = a.foo (0);
  constexpr int j = a.bar (0);
  static_assert (i == j, "Ouch");
}
开发者ID:ChaosJohn,项目名称:gcc,代码行数:8,代码来源:constexpr-ref4.C

示例2: refs_and_vals

void refs_and_vals() {
  // The following tests check that the transform correctly preserves the
  // reference or value qualifiers of the aliased variable. That is, if the
  // variable was declared as a value, the loop variable will be declared as a
  // value and vice versa for references.

  S s;
  const S s_const = s;

  for (S::const_iterator it = s_const.begin(); it != s_const.end(); ++it) {
    MutableVal alias = *it;
    {}
    alias.x = 0;
  }
  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
  // CHECK-FIXES: for (auto alias : s_const)
  // CHECK-FIXES-NOT: MutableVal {{[a-z_]+}} =
  // CHECK-FIXES: {}
  // CHECK-FIXES-NEXT: alias.x = 0;

  for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) {
    MutableVal alias = *it;
    {}
    alias.x = 0;
  }
  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
  // CHECK-FIXES: for (auto alias : s)
  // CHECK-FIXES-NOT: MutableVal {{[a-z_]+}} =
  // CHECK-FIXES: {}
  // CHECK-FIXES-NEXT: alias.x = 0;

  for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) {
    MutableVal &alias = *it;
    {}
    alias.x = 0;
  }
  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
  // CHECK-FIXES: for (auto & alias : s)
  // CHECK-FIXES-NOT: MutableVal &{{[a-z_]+}} =
  // CHECK-FIXES: {}
  // CHECK-FIXES-NEXT: alias.x = 0;

  dependent<int> dep, other;
  for (dependent<int>::iterator it = dep.begin(), e = dep.end(); it != e; ++it) {
    printf("%d\n", *it);
    const int& idx = other[0];
    unsigned othersize = other.size();
  }
  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
  // CHECK-FIXES: for (auto & elem : dep)
  // CHECK-FIXES-NEXT: printf("%d\n", elem);
  // CHECK-FIXES-NEXT: const int& idx = other[0];
  // CHECK-FIXES-NEXT: unsigned othersize = other.size();

  for (int i = 0, e = dep.size(); i != e; ++i) {
    int idx = other.at(i);
  }
}
开发者ID:urho3d,项目名称:clang-tools-extra,代码行数:58,代码来源:modernize-loop-convert-extra.cpp

示例3: refs_and_vals

void refs_and_vals() {
  // The following tests check that the transform correctly preserves the
  // reference or value qualifiers of the aliased variable. That is, if the
  // variable was declared as a value, the loop variable will be declared as a
  // value and vice versa for references.

  S Ss;
  const S S_const = Ss;

  for (S::const_iterator It = S_const.begin(); It != S_const.end(); ++It) {
    MutableVal Alias = *It;
    {}
    Alias.X = 0;
  }
  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
  // CHECK-FIXES: for (auto Alias : S_const)
  // CHECK-FIXES-NOT: MutableVal {{[a-z_]+}} =
  // CHECK-FIXES-NEXT: {}
  // CHECK-FIXES-NEXT: Alias.X = 0;

  for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
    MutableVal Alias = *It;
    {}
    Alias.X = 0;
  }
  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
  // CHECK-FIXES: for (auto Alias : Ss)
  // CHECK-FIXES-NOT: MutableVal {{[a-z_]+}} =
  // CHECK-FIXES-NEXT: {}
  // CHECK-FIXES-NEXT: Alias.X = 0;

  for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
    MutableVal &Alias = *It;
    {}
    Alias.X = 0;
  }
  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
  // CHECK-FIXES: for (auto & Alias : Ss)
  // CHECK-FIXES-NOT: MutableVal &{{[a-z_]+}} =
  // CHECK-FIXES-NEXT: {}
  // CHECK-FIXES-NEXT: Alias.X = 0;

  dependent<int> Dep, Other;
  for (dependent<int>::iterator It = Dep.begin(), E = Dep.end(); It != E; ++It) {
    printf("%d\n", *It);
    const int& Idx = Other[0];
    unsigned Othersize = Other.size();
  }
  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
  // CHECK-FIXES: for (int & It : Dep)
  // CHECK-FIXES-NEXT: printf("%d\n", It);
  // CHECK-FIXES-NEXT: const int& Idx = Other[0];
  // CHECK-FIXES-NEXT: unsigned Othersize = Other.size();

  for (int I = 0, E = Dep.size(); I != E; ++I) {
    int Idx = Other.at(I);
  }
}
开发者ID:berenm,项目名称:swang,代码行数:58,代码来源:modernize-loop-convert-extra.cpp

示例4: multipleEnd

void multipleEnd() {
  for (S::iterator i = s.begin(); i != s.end(); ++i)
    MutableVal k = *i;

  for (T::iterator i = t.begin(); i != t.end(); ++i)
    int k = *i;

  for (U::iterator i = u.begin(); i != u.end(); ++i)
    Val k = *i;
}
开发者ID:sam-panzer,项目名称:clang-loop-converter,代码行数:10,代码来源:negative-multi-end-call.cpp

示例5: example

void example()
{
  S s;
  s.func();
  static_cast<const S&>(s).func();
  static_cast<volatile S&>(s).func();

  const S sc;
  sc.increment();
}
开发者ID:cpp-pocketref,项目名称:sample-code,代码行数:10,代码来源:017_class.cpp

示例6: main

int main() {
    S s1;
    const S s2;
    volatile S s3;
    const volatile S s4;
    
    s1.foo();
    s2.foo();
    s3.foo();
    s4.foo();
}
开发者ID:CCJY,项目名称:coliru,代码行数:11,代码来源:main.cpp

示例7: operator

 int operator()(Concept) {
   auto t = get_table<typename Concept::Table>(src->table()->type_info, src);
   if (!t) {
     std::cerr << "get concept " << typeid(Concept).name()
               << " table for type " << src->table()->type_info->name()
               << " failed when castting from " << typeid(S).name() << " to "
               << typeid(D).name() << std::endl;
     abort();
   }
   *static_cast<typename Concept::Table *>(table) = *t;
   return 0;
 }
开发者ID:zuoyan,项目名称:smo_any,代码行数:12,代码来源:any_cast.hpp

示例8: GvmResult

 GvmResult(GvmCluster<S,V,K,FP> cluster)
 : space(cluster.clusters.space)
 {
   count = cluster.count;
   mass = cluster.m0;
   variance = cluster.var / mass;
   stdDeviation = FP(-1.0);
   key = cluster.getKey();
   //space = cluster.clusters.space;
   point = space.newCopy(cluster.m1);
   space.scale(point, FP(1.0) / mass);
 }
开发者ID:mdejong,项目名称:GvmCpp,代码行数:12,代码来源:GvmResult.hpp

示例9: main

int main()
{
    static S x;
    static T y;
    V *p;

    x.foo(17);
    p = &x;
    p->foo(18);
    p = &y;
    p->foo(12);
    _PASS;
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:13,代码来源:cdisp3.c

示例10: main

int main( void )
{
    bare();
    sv.smemb();
    tv.tmemb();

    _PASS;
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:8,代码来源:hier04.c

示例11: main

int main()
{
    {
    typedef std::string S;
    const S s;
    assert(s.front() == 0);
    assert(false);
    }
#if __cplusplus >= 201103L
    {
    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
    const S s;
    assert(s.front() == 0);
    assert(false);
    }
#endif
}
开发者ID:32bitmicro,项目名称:riscv-libcxx,代码行数:17,代码来源:db_cfront.pass.cpp

示例12: main

int main()
{
    {
    typedef std::string S;
    const S s;
    assert(s.front() == 0);
    assert(false);
    }
#if TEST_STD_VER >= 11
    {
    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
    const S s;
    assert(s.front() == 0);
    assert(false);
    }
#endif
}
开发者ID:Aj0Ay,项目名称:libcxx,代码行数:17,代码来源:db_cfront.pass.cpp

示例13: toString

 std::string toString() {
   std::stringstream sb;
   char buffer[100];
   
   sb << space.toString(point);
   
   // FIXME: use generic toString() method defined on the specific key type
   
   snprintf(buffer, 100, "  count: %d  variance: %3.3f  mass: %3.3f  key: %p", count, variance, mass, key);
   sb << buffer;
         
   return sb.str();
 }
开发者ID:mdejong,项目名称:GvmCpp,代码行数:13,代码来源:GvmResult.hpp

示例14: refs_and_vals

void refs_and_vals() {
  // The following tests check that the transform correctly preserves the
  // reference or value qualifiers of the aliased variable. That is, if the
  // variable was declared as a value, the loop variable will be declared as a
  // value and vice versa for references.

  S s;
  const S s_const = s;

  for (S::const_iterator it = s_const.begin(); it != s_const.end(); ++it) {
    MutableVal alias = *it; { }
    alias.x = 0;
  }
  // CHECK: for (auto alias : s_const)
  // CHECK-NOT: MutableVal {{[a-z_]+}} =
  // CHECK-NEXT: { }
  // CHECK-NEXT: alias.x = 0;

  for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) {
    MutableVal alias = *it; { }
    alias.x = 0;
  }
  // CHECK: for (auto alias : s)
  // CHECK-NOT: MutableVal {{[a-z_]+}} =
  // CHECK-NEXT: { }
  // CHECK-NEXT: alias.x = 0;

  for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) {
    MutableVal &alias = *it; { }
    alias.x = 0;
  }
  // CHECK: for (auto & alias : s)
  // CHECK-NOT: MutableVal &{{[a-z_]+}} =
  // CHECK-NEXT: { }
  // CHECK-NEXT: alias.x = 0;
}
开发者ID:DanielJump,项目名称:swang,代码行数:36,代码来源:naming-alias.cpp

示例15:

 string_out_iterator& operator=(typename S::value_type v) 
 { 
    out->append(1, v); 
    return *this; 
 }
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:5,代码来源:regex_timer.cpp


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