本文整理汇总了C++中X类的典型用法代码示例。如果您正苦于以下问题:C++ X类的具体用法?C++ X怎么用?C++ X使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了X类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: unordered_map_functions
void unordered_map_functions(X&, Key const& k, T const&)
{
typedef BOOST_DEDUCED_TYPENAME X::mapped_type mapped_type;
X a;
test::check_return_type<mapped_type>::equals_ref(a[k]);
test::check_return_type<mapped_type>::equals_ref(a.at(k));
X const b = a;
test::check_return_type<mapped_type const>::equals_ref(b.at(k));
}
开发者ID:,项目名称:,代码行数:11,代码来源:
示例2: main
int main() {
cout << "main() invoked" << endl;
//f5() = X(1); // OK -- non-const return value
const X x = f5() = X(1);
x.output();
//f5().modify(); // OK
// Causes compile-time errors:
//! f7(f5());
//! f6() = X(1);
//! f6().modify();
//! f7(f6());
} ///:~
开发者ID:,项目名称:,代码行数:12,代码来源:
示例3: main
int main()
{
X x1;
const X x2 = x1;
volatile X x3;
volatile const X x4 = x2;
x1.display();
x2.display();
x3.display();
x4.display();
return 0;
}
开发者ID:amitesh-singh,项目名称:algorithms,代码行数:14,代码来源:volatile_memfunction.cpp
示例4: foo
namespace at_ns_scope_within_class_member {
struct X {
static void foo(double d) { }
auto test() {
auto L = [](auto a) {
print("a = ", a, "\n");
foo(a);
return [](decltype(a) b) {
foo(b);
foo(sizeof(a) + sizeof(b));
return [](auto ... c) {
print("c = ", c ..., "\n");
foo(decltype(b){});
foo(sizeof(decltype(a)*) + sizeof(decltype(b)*));
return [](decltype(c) ... d) ->decltype(a) { //expected-note{{candidate}}
print("d = ", d ..., "\n");
foo(decltype(b){});
foo(sizeof(decltype(a)*) + sizeof(decltype(b)*));
return decltype(a){};
};
};
};
};
return L;
}
};
X x;
auto L = x.test();
auto L_test = L('4');
auto M = L('3');
auto M_test = M('a');
auto N = M('x');
auto O = N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
char (*np)(const char*, int, const char*, double, const char*, int) = O;
auto NP_result = np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
int (*np2)(const char*, int, const char*, double, const char*, int) = O; // expected-error{{no viable conversion}}
} //end at_ns_scope_within_class_member
开发者ID:,项目名称:,代码行数:38,代码来源:
示例5: unordered_test
void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq)
{
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
typedef BOOST_DEDUCED_TYPENAME X::hasher hasher;
typedef BOOST_DEDUCED_TYPENAME X::key_equal key_equal;
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<iterator>::type iterator_category;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<iterator>::type iterator_difference;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<iterator>::type iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<iterator>::type iterator_reference;
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<local_iterator>::type local_iterator_category;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<local_iterator>::type local_iterator_difference;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<local_iterator>::type local_iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<local_iterator>::type local_iterator_reference;
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<const_iterator>::type const_iterator_category;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<const_iterator>::type const_iterator_difference;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_iterator>::type const_iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<const_iterator>::type const_iterator_reference;
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<const_local_iterator>::type const_local_iterator_category;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<const_local_iterator>::type const_local_iterator_difference;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_local_iterator>::type const_local_iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<const_local_iterator>::type const_local_iterator_reference;
BOOST_MPL_ASSERT((boost::is_same<Key, key_type>));
boost::function_requires<boost::CopyConstructibleConcept<key_type> >();
boost::function_requires<boost::AssignableConcept<key_type> >();
BOOST_MPL_ASSERT((boost::is_same<Hash, hasher>));
test::check_return_type<std::size_t>::equals(hf(k));
BOOST_MPL_ASSERT((boost::is_same<Pred, key_equal>));
test::check_return_type<bool>::convertible(eq(k, k));
boost::function_requires<boost::InputIteratorConcept<local_iterator> >();
BOOST_MPL_ASSERT((boost::is_same<local_iterator_category, iterator_category>));
BOOST_MPL_ASSERT((boost::is_same<local_iterator_difference, iterator_difference>));
BOOST_MPL_ASSERT((boost::is_same<local_iterator_pointer, iterator_pointer>));
BOOST_MPL_ASSERT((boost::is_same<local_iterator_reference, iterator_reference>));
boost::function_requires<boost::InputIteratorConcept<const_local_iterator> >();
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_category, const_iterator_category>));
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_difference, const_iterator_difference>));
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_pointer, const_iterator_pointer>));
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_reference, const_iterator_reference>));
X(10, hf, eq);
X a(10, hf, eq);
X(10, hf);
X a2(10, hf);
X(10);
X a3(10);
X();
X a4;
BOOST_DEDUCED_TYPENAME X::value_type* i = 0;
BOOST_DEDUCED_TYPENAME X::value_type* j = 0;
X(i, j, 10, hf, eq);
X a5(i, j, 10, hf, eq);
X(i, j, 10, hf);
X a6(i, j, 10, hf);
X(i, j, 10);
X a7(i, j, 10);
X(i, j);
X a8(i, j);
X const b;
sink(X(b));
X a9(b);
a = b;
test::check_return_type<hasher>::equals(b.hash_function());
test::check_return_type<key_equal>::equals(b.key_eq());
const_iterator q = a.cbegin();
test::check_return_type<iterator>::equals(a.insert(q, t));
test::check_return_type<iterator>::equals(a.emplace_hint(q, t));
a.insert(i, j);
test::check_return_type<size_type>::equals(a.erase(k));
BOOST_TEST(a.empty());
if(a.empty()) {
a.insert(t);
q = a.cbegin();
test::check_return_type<iterator>::equals(a.erase(q));
}
const_iterator q1 = a.cbegin(), q2 = a.cend();
test::check_return_type<iterator>::equals(a.erase(q1, q2));
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
示例6: container_test
void container_test(X& r, T const&)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME X::difference_type difference_type;
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<iterator>::type iterator_value_type;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<const_iterator>::type const_iterator_value_type;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<iterator>::type iterator_difference_type;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<const_iterator>::type const_iterator_difference_type;
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
typedef BOOST_DEDUCED_TYPENAME X::reference reference;
typedef BOOST_DEDUCED_TYPENAME X::const_reference const_reference;
// value_type
BOOST_MPL_ASSERT((boost::is_same<T, value_type>));
boost::function_requires<boost::CopyConstructibleConcept<X> >();
// reference_type / const_reference_type
BOOST_MPL_ASSERT((boost::is_same<T&, reference>));
BOOST_MPL_ASSERT((boost::is_same<T const&, const_reference>));
// iterator
boost::function_requires<boost::InputIteratorConcept<iterator> >();
BOOST_MPL_ASSERT((boost::is_same<T, iterator_value_type>));
BOOST_MPL_ASSERT((boost::is_convertible<iterator, const_iterator>));
// const_iterator
boost::function_requires<boost::InputIteratorConcept<const_iterator> >();
BOOST_MPL_ASSERT((boost::is_same<T, const_iterator_value_type>));
// difference_type
BOOST_MPL_ASSERT((boost::mpl::bool_<
std::numeric_limits<difference_type>::is_signed>));
BOOST_MPL_ASSERT((boost::mpl::bool_<
std::numeric_limits<difference_type>::is_integer>));
BOOST_MPL_ASSERT((boost::is_same<difference_type,
iterator_difference_type>));
BOOST_MPL_ASSERT((boost::is_same<difference_type,
const_iterator_difference_type>));
// size_type
BOOST_MPL_ASSERT_NOT((boost::mpl::bool_<
std::numeric_limits<size_type>::is_signed>));
BOOST_MPL_ASSERT((boost::mpl::bool_<
std::numeric_limits<size_type>::is_integer>));
// size_type can represent any non-negative value type of difference_type
// I'm not sure about either of these tests...
size_type max_diff((std::numeric_limits<difference_type>::max)());
difference_type converted_diff(max_diff);
BOOST_TEST((std::numeric_limits<difference_type>::max)()
== converted_diff);
BOOST_TEST(
static_cast<comparison_type>(
(std::numeric_limits<size_type>::max)()) >
static_cast<comparison_type>(
(std::numeric_limits<difference_type>::max)()));
// I don't test the runtime post-conditions here.
X u;
BOOST_TEST(u.size() == 0);
BOOST_TEST(X().size() == 0);
X a,b;
sink(X(a));
X u2(a);
X u3 = a;
X* ptr = new X();
X& a1 = *ptr;
(&a1)->~X();
X const a_const;
test::check_return_type<iterator>::equals(a.begin());
test::check_return_type<const_iterator>::equals(a_const.begin());
test::check_return_type<const_iterator>::equals(a.cbegin());
test::check_return_type<const_iterator>::equals(a_const.cbegin());
test::check_return_type<iterator>::equals(a.end());
test::check_return_type<const_iterator>::equals(a_const.end());
test::check_return_type<const_iterator>::equals(a.cend());
test::check_return_type<const_iterator>::equals(a_const.cend());
a.swap(b);
test::check_return_type<X>::equals_ref(r = a);
test::check_return_type<size_type>::equals(a.size());
test::check_return_type<size_type>::equals(a.max_size());
test::check_return_type<bool>::convertible(a.empty());
// Allocator
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
示例7: main
int main() {
X x1(10);
const X x2(20);
x1.f();
x2.f();
} ///:~
开发者ID:BigR-Lab,项目名称:CodeRes_Cpp,代码行数:6,代码来源:ConstMember.cpp
示例8: main
int main() {
dstY = dstX = srcX;
srcX.pr();
dstX.pr();
dstY.pr();
}
开发者ID:4ntoine,项目名称:clang,代码行数:6,代码来源:copy-assign-synthesis-1.cpp
示例9: show
void show(){ cout<<"class C, show\n";
cout<<(s?s:"0")<<endl;
// cout<<a.i<<endl; // kein Zugriff !
a.display();
p->display();
r.display();
}
开发者ID:genericFJS,项目名称:htw,代码行数:7,代码来源:Enth1.cpp
示例10: permute
void permute() { x.permute(); }
开发者ID:archfp,项目名称:floorplan,代码行数:1,代码来源:Composition2.cpp
示例11: xxx
开发者ID:pjump,项目名称:gcc,代码行数:3,代码来源:niklas02.C
示例12: f
void f(int ii) { i = ii; x.set(ii); }
开发者ID:archfp,项目名称:floorplan,代码行数:1,代码来源:Composition2.cpp
示例13: g
int g() const { return i * x.read(); }
开发者ID:archfp,项目名称:floorplan,代码行数:1,代码来源:Composition2.cpp
示例14: asignar
void asignar(int i,char c) { x.asignar (i,c); }
开发者ID:agudeloandres,项目名称:C_Struct_Files,代码行数:1,代码来源:P119.CPP
示例15: F
int F(char *p) {
int i = x.G(p);
return i;
}
开发者ID:agudeloandres,项目名称:C_Struct_Files,代码行数:4,代码来源:P119.CPP
示例16: foobar
void foobar()
{
x.foo();
}
开发者ID:alexjohn1362,项目名称:rose,代码行数:4,代码来源:test2005_156.C
示例17: show
void show()
{
res.show();
}
开发者ID:GeorgiyDemo,项目名称:archives,代码行数:4,代码来源:Example12_11.cpp
示例18: y
void A::y()
{
const char *const a[] = { x.c() };
f (a[0]);
}
开发者ID:VargMon,项目名称:dd-wrt,代码行数:5,代码来源:sibcall2.C
注:本文中的X类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论