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

  • Home
  • SEARCH
  • 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 8841803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:48:38+00:00 2026-06-14T10:48:38+00:00

A basic C++ 03 enumerated type is just an integral value with a fancy

  • 0

A basic C++ 03 enumerated type is just an integral value with a fancy name, therefore I would expect to pass it by value….

For this reason I would also expect boost::call_traits<T>::param_type with T=SomeEnum to determine that the most efficient way of pass T is by value.

From boost documentation see Call Traits:

Defines a type that represents the “best” way to pass a parameter of type T to a function.

When I use boost::call_traits<T>::param_type with T=SomeEnum it determines that SomeEnum should be passed by reference.

I would also expect C++11 class enums to also be passed by value.

Test Code:

#include <string>
#include <typeinfo>
#include <boost/call_traits.hpp>
#include <boost/type_traits/is_reference.hpp>

enum SomeEnum
{
    EN1_ZERO = 0,
    EN1_ONE,
    EN1_TWO,
    EN1_THREE
};

struct SomeStruct
{};

template<typename T>
void DisplayCallTraits( const std::string& desc )
{
    typedef typename boost::call_traits<T>::param_type param_type;
    std::cout << "-----------------------------------------------------\n";
    std::cout << "Call traits for: " << desc << "\n";
    std::cout << "\ttypeof T : " << typeid(T).name() << "\n";
    std::cout << "\ttypeof param_type : " << typeid(param_type).name() << "\n";
    std::cout << "\tis_reference<param_type> : " << std::boolalpha 
              << boost::is_reference<param_type>::value << "\n";
}

int main( int, char** )
{
    DisplayCallTraits< unsigned >( "unsigned" );     // pass by value, as expected
    DisplayCallTraits< SomeStruct >( "struct" );     // pass by reference, as expected
    DisplayCallTraits< SomeEnum >( "enumeration" );  // pass by reference - why?

    return 0;
}
  • 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-06-14T10:48:40+00:00Added an answer on June 14, 2026 at 10:48 am

    This has been updated to include a check to is_enum in the implementation. See this bug report, closed 2 months ago: https://svn.boost.org/trac/boost/ticket/5790

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

Sidebar

Related Questions

I have an enumerated type that I would like to define the > ,
Basic C# syntax question: So I have this class public class BrandQuery<T> : Query<T>
Basic problem I have some large, but logically organised documents - and would like
Basic c# question. In the sample bellow But the 'is' doesn't like the type
Basic question but I've searched and can't quite get this nailed - how can
I understand that the basic for...of syntax in JavaScript looks like this: for (let
Basic question here - I have many lines of code that look something like:
Basic question here. I started using ARC and am not sure if I should
Basic doubt...If QTP generates vbscript code as we record actions, can't we directly write
Basic question - is it possible to access the current Page from a static

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.