本文整理汇总了C++中boost::ref方法的典型用法代码示例。如果您正苦于以下问题:C++ boost::ref方法的具体用法?C++ boost::ref怎么用?C++ boost::ref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost
的用法示例。
在下文中一共展示了boost::ref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLoggedInUser
UserData ClientServiceImpl::getLoggedInUser() const{
ScopeGuard fbCritSectGuard(
bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)),
bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect)));
return _currentData.getLoggedInUser();
}
示例2: getGroupsInvsCount
size_t ClientServiceImpl::getGroupsInvsCount() const{
ScopeGuard fbCritSectGuard(
bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)),
bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect)));
NotificationsData nftnDta = _currentData.getNotificationsData();
return nftnDta.getGroupsInvsCount();
}
示例3: getPokesCount
size_t ClientServiceImpl::getPokesCount() const{
// lock on construction, unlock on destruction
ScopeGuard fbCritSectGuard(
bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)),
bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect)));
NotificationsData nftnDta = _currentData.getNotificationsData();
return nftnDta.getPokesCount();
}
示例4: cleanUpCollectedData
void ClientServiceImpl::cleanUpCollectedData() {
ScopeGuard fbCritSectGuard(
bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)),
bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect)));
_toolbarNotifications.clear();
_friendsChangesPopupNotifications.clear();
_albumsChanges.clear();
_popupSelfNotifications.clear();
ServiceData emptyData;
_currentData = emptyData;
}
示例5: options
OD grammar_args::options()
{
namespace po = boost::program_options;
using std::string;
using boost::bind;
using boost::ref;
using namespace graehl;
OD od("grammar options");
od.add_options()
("grammar-archive,g", defaulted_value(&grammar_archive),
"archived translation rules grammar")
( "grammar-format,f"
, defaulted_value(&grammar_format),
"legal values: brf, archive(default), fat-archive, "
"text-archive, fat-text-archive"
)
("weight-file,w"
,po::value<string>()->notifier(bind(&weights_from_file,ref(*this),_1))
,"file with feature and lm exponents (weights), "
"single or multiple lines of: a:-1,b:2.5")
("weight-string"
,po::value<string>()->notifier(bind(&weights_from_string,ref(*this),_1))
,"same format as weights file; completely overrides any --weight-file")
("verbose-non-numeric", defaulted_value(&verbose),
"complain to STDERR about nonnumeric rule attributes")
("final-weights-to", defaulted_value(&final_weights_to),
"print weights finally used here (same format as weight-string/file)")
;
OD prior_opts("Heuristic (English) per-tag prior probability options");
prior_opts.add_options()
("prior-file", defaulted_value(&prior_file),
"file with alternating <tag> <count> e.g. NP 123478. virtual tags ignored")
("prior-floor-prob", defaulted_value(&prior_floor_prob),
"minimum probability for missing or low-count tags")
("prior-bonus-count", defaulted_value(&prior_bonus_count),
"give every tag that appears in prior-file this many extra counts (before normalization)")
("weight-prior", defaulted_value(&weight_tag_prior),
"raise prior prob to this power for rule heuristic")
("tag-prior-bonus", defaulted_value(&grammar.tag_prior_bonus),
"constant prior multiplied into (nonvirtual) tag heuristic. greater than 1 <=> favor tags more than virtuals")
;
od.add(prior_opts);
OD feature_opts("(nonnumeric) feature options");
feature_opts.add_options()
("keep-text-features",defaulted_value(&keep_texts),
"Keep the unused nonnumeric features in memory")
("keep-align",defaulted_value(&keep_align),
"parse the 'align' attribute for word/variable alignments")
;
od.add(feature_opts);
return od;
}
示例6: f
std::string f(ArgumentPack const& args)
{
std::string const& s1 = args[_s1];
std::string const& s2 = args[_s2];
#line 1905 "../../../../libs/parameter/doc/index.rst"
using boost::bind;
using boost::ref;
typename parameter::binding<
ArgumentPack, tag::s3, std::string
>::type s3 = args[_s3 || bind(std::plus<std::string>(), ref(s1), ref(s2)) ];
#line 1931 "../../../../libs/parameter/doc/index.rst"
return s3;
}
示例7: Convolve
// Run a tweaked sobel convolution
void FastSobel::Convolve(const ImageF& input,
ImageF& output,
const int direction) {
if (*gvParallelize) {
ParallelPartition(input.GetHeight(),
bind(&ConvolveRowRange,
ref(input),
ref(output),
direction,
_1,
_2));
} else {
ConvolveRowRange(input, output, direction, 0, input.GetHeight()-1);
}
}
示例8: findOverlap
static void findOverlap(const Graph& g,
ContigID refID, bool rc,
const ContigNode& pair,
const DistanceEst& est,
OverlapGraph& out)
{
if (refID == pair.id()
|| (est.distance >= 0 && !opt::scaffold))
return;
ContigNode ref(refID, false);
const ContigNode& t = rc ? pair : ref;
const ContigNode& h = rc ? ref : pair;
if (out_degree(t, g) > 0 || in_degree(h, g) > 0
|| edge(t, h, out).second)
return;
bool mask = false;
unsigned overlap
= est.distance - (int)allowedError(est.stdDev) <= 0
? findOverlap(g, t, h, mask) : 0;
if (mask && !opt::mask)
return;
if (overlap > 0 || opt::scaffold)
add_edge(t, h, Overlap(est, overlap, mask), out);
}
示例9: test_member_functions
void test_member_functions()
{
using boost::ref;
A a(10);
int i = 1;
BOOST_TEST(bind(&A::add, ref(a), _1)(i) == 11);
BOOST_TEST(bind(&A::add, &a, _1)(i) == 11);
BOOST_TEST(bind(&A::add, _1, 1)(a) == 11);
BOOST_TEST(bind(&A::add, _1, 1)(make_const(&a)) == 11);
BOOST_TEST(bind(&A::add2, _1, 1, 1)(a) == 12);
BOOST_TEST(bind(&A::add3, _1, 1, 1, 1)(a) == 13);
BOOST_TEST(bind(&A::add4, _1, 1, 1, 1, 1)(a) == 14);
BOOST_TEST(bind(&A::add5, _1, 1, 1, 1, 1, 1)(a) == 15);
BOOST_TEST(bind(&A::add6, _1, 1, 1, 1, 1, 1, 1)(a) == 16);
BOOST_TEST(bind(&A::add7, _1, 1, 1, 1, 1, 1, 1, 1)(a) == 17);
BOOST_TEST(bind(&A::add8, _1, 1, 1, 1, 1, 1, 1, 1, 1)(a) == 18);
// This should fail, as lambda functors store arguments as const
// bind(&A::add, a, _1);
}
示例10: FireUpdates
void ClientServiceImpl::FireUpdates(ClientService* clientService) {
ScopeGuard fbCritSectGuard(
bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)),
bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect)));
// fire updates about my changes
while(!_toolbarNotifications.empty()) {
const DataChangeEvents eventID = _toolbarNotifications.front();
_toolbarNotifications.pop_front();
try{
clientService->Fire_dataUpdated(eventID);
}
catch(...) {
}
if (!initialUpdate_) {
showSelfNotification(eventID, _currentData);
}
}
// fier notifications about self changes
while(!_popupSelfNotifications.empty()) {
const DataChangeEvents changeID = _popupSelfNotifications.front();
_popupSelfNotifications.pop_front();
showSelfNotification(changeID, _currentData);
}
// fire updates about my friends
while(!_friendsChangesPopupNotifications.empty()) {
const EventToFriendIDs eventToFriendIDs = _friendsChangesPopupNotifications.front();
_friendsChangesPopupNotifications.pop_front();
const DataChangeEvents changeID = eventToFriendIDs.first;
const FriendsIDs friendsIDs = eventToFriendIDs.second;
showFriendsChangePopup(changeID, friendsIDs, _currentData);
}
// fire updates about albums
while(!_albumsChanges.empty()) {
const EventsToAlbumsIDs eventToAlbumIDs = _albumsChanges.front();
_albumsChanges.pop_front();
const DataChangeEvents changeID = eventToAlbumIDs.first;
const AlbumsIDs albumsIDs = eventToAlbumIDs.second;
showAlbumsChangePopup(changeID, albumsIDs, _currentData);
}
initialUpdate_ = false;
}
示例11: ref
/**
* Retrieve an IEnumIDList to enumerate this directory's contents.
*
* This function returns an enumerator which can be used to iterate through
* the contents of this directory as a series of PIDLs. This listing is a
* @b copy of the one obtained from the server and will not update to reflect
* changes. In order to obtain an up-to-date listing, this function must be
* called again to get a new enumerator.
*
* @param flags Flags specifying nature of files to fetch.
*
* @returns Smart pointer to the IEnumIDList.
* @throws com_error if an error occurs.
*/
com_ptr<IEnumIDList> CSftpDirectory::GetEnum(SHCONTF flags)
{
// Interpret supported SHCONTF flags
bool include_folders = (flags & SHCONTF_FOLDERS) != 0;
bool include_non_folders = (flags & SHCONTF_NONFOLDERS) != 0;
bool include_hidden = (flags & SHCONTF_INCLUDEHIDDEN) != 0;
vector<sftp_filesystem_item> directory_enum = m_provider->listing(
m_directory);
// XXX: PERFORMANCE:
// For a link, we look its target details up 3 times! Once to see if it is
// a directory, once to see if it isn't a directory and once to see if its
// a directory whilst converting to PIDL. This info should be cached in
// the sftp_filesystem_item
function<bool(const sftp_filesystem_item&)> hidden_filter =
include_hidden || !bind(is_dotted, _1);
function<bool(const sftp_filesystem_item&)> directory_filter =
include_folders ||
!bind(is_directory, _1, m_directory, ref(*m_provider));
function<bool(const sftp_filesystem_item&)> non_directory_filter =
include_non_folders ||
bind(is_directory, _1, m_directory, ref(*m_provider));
function<cpidl_t(const sftp_filesystem_item&)> pidl_converter =
bind(
convert_directory_entry_to_pidl, _1, m_directory, ref(*m_provider));
shared_ptr< vector<cpidl_t> > pidls = make_shared< vector<cpidl_t> >();
boost::copy(
directory_enum |
filtered(hidden_filter) |
filtered(directory_filter) |
filtered(non_directory_filter) |
transformed(pidl_converter),
back_inserter(*pidls));
return make_smart_enumeration<IEnumIDList>(pidls);
}
示例12: setName
void TextWindow::setName(const std::string& utf8name,
const std::string& next_char) {
if (name_mod_ == 0) {
// Display the name in one pass
printTextToFunction(bind(&TextWindow::character, ref(*this), _1, _2),
utf8name, next_char);
setIndentation();
}
setNameWithoutDisplay(utf8name);
}
示例13: main
int main()
{
fusion::vector<int,char> lv_vec(1,'\004');
test_func<> f;
test_func<noncopyable> f_nc;
fusion::result_of::make_fused_procedure< test_func<> >::type fused_func
= fusion::make_fused_procedure(f);
CHECK_EFFECT(fused_func(lv_vec), 1);
CHECK_EFFECT(const_(fused_func)(lv_vec), 0);
CHECK_EFFECT(fusion::make_fused_procedure(const_(f))(lv_vec), 1);
CHECK_EFFECT(fusion::make_fused_procedure(ref(f_nc))(lv_vec), 1);
CHECK_EFFECT(fusion::make_fused_procedure(cref(f_nc))(lv_vec), 0);
CHECK_EFFECT(fused_func(fusion::make_vector(2,'\003')), 1);
CHECK_EFFECT(const_(fused_func)(fusion::make_vector(2,'\003')), 0);
CHECK_EFFECT(fusion::make_fused_procedure(const_(f))(fusion::make_vector(2,'\003')), 1);
CHECK_EFFECT(fusion::make_fused_procedure(ref(f_nc))(fusion::make_vector(2,'\003')), 1);
CHECK_EFFECT(fusion::make_fused_procedure(cref(f_nc))(fusion::make_vector(2,'\003')), 0);
return boost::report_errors();
}
示例14: main
int main(int argc, char* argv[])
{
if( argc < 2 ){
printf("%s", usage);
return 1;
}
int len = atoi(argv[1] );
if( len < 3 || len > 12 ){
printf("%s", usage);
return 2;
}
int fact[16];
fact[0] = 1;
for(int i = 1; i<len+1; ++i)
fact[i] = fact[i-1]*i;
unsigned n_cpu = thread::hardware_concurrency();
Fannkuchredux::R r= { 0, 0};
const unsigned max_cpu_limit = 4;
Task parts[max_cpu_limit];
unsigned n = min(n_cpu, max_cpu_limit);
thread_group tg;
int index = 0;
int index_max = fact[len];
int index_step = (index_max + n-1)/n;
for(unsigned i = 0; i<n; ++i, index += index_step){
Task& p = parts[i];
p.init(fact, len, index, index + index_step);
tg.create_thread(ref(p));
}
tg.join_all();
for(unsigned i = 0; i<n; ++i){
Task const& p = parts[i];
r.maxflips = max( p.r.maxflips, r.maxflips );
r.checksum += p.r.checksum;
}
printf("%d\nPfannkuchen(%d) = %d\n", r.checksum, len, r.maxflips);
return 0;
}
示例15: ref
Worker::Worker()
: consumer_thread(bind(&Worker::ConsumeLoop, ref(*this))),
join_barrier(2),
alive(true) {
}