C++ boost::function::function_base














































C++ boost::function::function_base



Description: The common base class  for all boost::function objects. Objects of type function_base  may not be created directly. 

member functions:
empty(): it will return false  if it has the target which means the functor is not empty
               syntax: bool empty() count

function_base target access:

1.template<typename Functor> Functor* target();
   template<typename Functor> const Functor* target() const;
    about: if this stores a target of type functor, returns the address of the target  otherwise returns the null pointer

2.template<typename Functor> bool contains(const Functor& f) const;
  about :it returns true if this-> target<Functor>() is non null 

Program:

#include <boost/function.hpp>// the main header file 
#include<boost/math/common_factor.hpp>// the header file used for math functions #include <functional> #include <iostream> using namespace std; struct example { int demo(std::ostream &os,int a,int b) { os << "LCM of "<<a<<"and"<<b<<":"<<boost::math::lcm(a,b);//math function for finding lcm return 0; } }; int main() { boost::function<int(example*, std::ostream&, int,int)> f = &example::demo; // above is the boost::function target access template example w; if (f.empty()) /* this is function which used to check whether the function is empty or it has any value*/ cout << "f has no target, so it is unsafe to call" <<endl; else f(&w, std::ref(std::cout) , 10,20); }
output:
lcm of 10and20:20

More Articles of Konada Sunita:

Name Views Likes
C++ boost::accumulator::p_square_cumulative_distribution 672 1
C++ boost::Numeric Conversion::converter<> 864 10
C++ boost::ref 1227 9
C++ boost::accumulator::count 930 2
C++ boost::function::function_base 557 10
C++ boost::accumulator::weighted_mean 889 1
C++ boost::accumulator::non_coherent_weighted_tail_mean 563 1
C++ boost::accumulator::rolling_count rolling_sum rolling_mean rolling_moment 727 2
C++ boost::lockfree::spsc_queue 2202 10
C++ boost::coroutine:: passing data 640 1
C++ boost::accumulator::weighted_tail_quantile 619 1
C++ boost::TokenizerClass 83 2
C++ boost::accumulator::weighted_variance 559 1
C++ boost::accumulator::rolling mean 2595 2
C++ boost::accumulator::median 1417 1
C++ boost::accumulator::extended_p_square_quantile 837 1
C++ boost::accumulator::extended_p_square 648 1
C++ boost::function::functionN 829 10
C++ boost::accumulator::weighted_density 505 1
C++ boost::accumulator::covariance density 780 3
C++ boost::accumulator::weighted_skewness 503 1
C++ boost::format::formatter 654 10
C++ boost::accumulator::skewness 911 1
C++ boost::accumulator::max 700 3
C++ boost::accumulator::variance 992 1
C++ boost::accumulator::min 592 2
C++ boost::accumulator::density 951 1
C++ boost::token_iterator 885 10
c++ program to print root to leaf paths without using recursion 704 10
C++ boost::accumulator::rolling variance 1476 4
C++ boost::accumulator::weighted_sum 544 1
C++ boost::accumulator::weighted_extended_p_square_quantile 605 2
C++ boost::accumulator::sum_kahan 1117 2
C++ boost::accumulator::weighted_moment 469 1
C++ boost::accumulator::error_of 658 2
C++ boost::accumulator::tail 845 2
C++ boost::format 4138 10
C++ boost::accumulator::weighted_p_square_cumulative_distribution 522 1
C++ boost::accumulator::coherent_tail_mean 471 1
C++ boost::accumulator::rolling count 1153 2
C++ boost::accumulator::moment 703 2
C++ boost::lockfree::stack 1207 8
C++ boost::accumulator::sum 821 2
C++ boost::function::bad_function_call() 1096 10
C++ boost::accumulators::Mean Moment Count 1370 2
C++ boost::accumulator::mean 1617 2
C++ boost::accumulator::non_coherent_tail_mean 501 1
C++ boost::accumulator::weighted_extended_p_square 521 1
C++ boost::accumulator::weighted_kurtosis 522 1
C++ boost::accumulator::covariance density error_of_mean 587 9
C++ boost::accumulator::rolling sum 834 2
C++ boost::lockfree::queue 3084 9
C++ boost::accumulator::weighted_p_square_quantile 852 1
C++ boost::accumulator::p_square_quantile 840 1
C++ boost::accumulator::tail_quantile 1201 1
C++ boost::accumulator::rolling moment 598 2
C++ boost::accumulator::min max 1230 3
C++ boost::accumulator::kurtosis 1209 1
C++ boost::coroutine::Pushtype and pulltype 1564 1
C++ boost::accumulator::tail_variate 491 2
C++ boost::accumulator::weighted_covariance 519 2
C++ boost::format::Exception 2202 10
C++ boost::function 3034 10
C++ boost::NumericConversion::bounds<> 677 10
C++ boost::NumericConversion::UDT 853 10

Comments