本文整理汇总了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");
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例6: main
int main() {
S s1;
const S s2;
volatile S s3;
const volatile S s4;
s1.foo();
s2.foo();
s3.foo();
s4.foo();
}
示例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;
}
示例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);
}
示例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;
}
示例10: main
int main( void )
{
bare();
sv.smemb();
tv.tmemb();
_PASS;
}
示例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
}
示例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
}
示例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();
}
示例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;
}
示例15:
string_out_iterator& operator=(typename S::value_type v)
{
out->append(1, v);
return *this;
}