Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7165979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:20:20+00:00 2026-05-28T14:20:20+00:00

The following function is defined for all arithmetic types: template <class T> typename enable_if_c<boost::is_arithmetic<T>::value,

  • 0

The following function is defined for all arithmetic types:

template <class T>
typename enable_if_c<boost::is_arithmetic<T>::value, T>::type 
foo(T t) { return t; }

Question 1> what does the value mean here? Why not simply use boost::is_arithmetic<T>?

boost::is_arithmetic<T>::value

Question 2> Does the type mean T?

Question 3> Is it true that boost::is_arithmetic<T>::value is only used to filter non-arithmetric and the function in fact only needs T?

Question 4> How to read the following statement?

template <typename T>
void dodah( T i, typename disable_if<is_integral<T> >::type* p=0 )
{
   cout << "I: " << i << endl;
}

Does it mean 1> disable integral type 2> only accept non-integral type and which has embedded type as type?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:20:21+00:00Added an answer on May 28, 2026 at 2:20 pm

    1) value is a boolean constant that will be define to true if T is arithmetic which in my version of boost means integral or float type.

    2) type is a typedef on T if is_arithmetic::value is true, otherwise it is not defined. Normally if type was not defined, one would think this wouldn’t compile, however as boost documentation states:

    Sensible operation of template function overloading in C++ relies on the SFINAE (substitution-failure-is-not-an-error) principle: if an invalid argument or return type is formed during the instantiation of a function template, the instantiation is removed from the overload resolution set instead of causing a compilation error

    This as the effect of removing this particular template function for template resolution when T is not arithmetic.

    3) Yes

    4) This read, do not use this template function if T is integral for template resolution. However in the case where you call the function with a non integral type, you do not want to have to pass a dummy second parameter, hence the default value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function defined inside my linked list class. The declaration in
The following function System.Threading.Thread.Sleep(); delay the thread in millisecond, and take the integer value
I am trying to do the following: boost::unordered_map<boost::flyweight<std::string>, boost::flyweight<std::string> > map; boost::flyweight<std::string> foo(name); map[foo]
I have a function defined as the following (in C): gchar **Scan_Return_File_Tag_Field_From_Mask_Code (File_Tag *FileTag,
Consider the following sequence of events: A view v_Foo is defined A user-defined function
I defined the following function, where List is a structure. List * LIST_Create() {
I'm using the following code to load in content: <script type=text/javascript> jQuery.noConflict(); jQuery(document).ready(function(){ jQuery('.content-div').load(all-events.html);
I've the following function defined in Excel: Function LongString() Dim i As Integer Do
I've defined the following JS constructor function function FV.Map(element) { // impl omitted }
I want to define a following function: if(stmtToFinalize) { NSLog(@Finalizing statement stmtToFinalize); if (sqlite3_finalize(stmtToFinalize)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.