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 3723566
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T06:19:06+00:00 2026-05-19T06:19:06+00:00

In C++, I sometimes end up with utility classes like this: struct time_ref {

  • 0

In C++, I sometimes end up with utility classes like this:

struct time_ref
{
   time_ref(FILETIME & ft) : ftval(&ft), ttval(0) {}
   time_ref(time_t & tt) : ttval(&tt), ftval(0) {}

   FILETIME * ftval; 
   time_t   * ttval;
}

They rely on implcit conversions e.g. to reduce the numner of overloads:

void Foo(int x, int y, time_ref t)

Rationale: if Foo has another parameter with overloads, the prototypes multiply, e.g. 3 overloads for X * 2 overloads for t is 6 prototypes, compared to 3 with above converter (or even one if two converters are used).


They always:

  • have implicit constructors for two or mroe types
  • should be used only as function parameters to enable these conversions

Thye differ in:

  • Number of types supported
  • can store a value, or a reference
  • how the callee detects what type was provided (in the case above, it’s the non-null pointer. Another typical implementation is an enum field and a union of data values)

Questions:

1. Is there an accepted / common name for this pattern? I usually call them “argument converter” or “argument adapter”, which doesn’t seem common

2. any recommendaitons to formalize them – e.g. is there a way (apart from adding a comment saying so) to ensure they are used only as parameters? Any other things to be aware of?

  • 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-19T06:19:07+00:00Added an answer on May 19, 2026 at 6:19 am

    A shim is often a good choice when you need to handle many different argument types, even after your interface is “done”. It allows you to do the conversion in a modular, fairly reusable way. See this wikipedia entry and its referenced articles for more information.

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

Sidebar

Related Questions

Sometimes I need a useful utility function, like List::Util::max in the middle of a
I've got a view which looks like this: <p><%= stage.end_date.strftime(%A, %d %B %Y)%></p> Sometimes
Sometimes we end up writing several methods something like: module XyzGateway module Defaults def
Sometimes when I copy javascript from jsfiddle into Dreamweaver I end up banging my
Sometimes, I'll end up having to catch an exception that I know can never
Sometimes in case of a bug in our code, we usually ask the end
Sometimes when using Visual Studio it displays a prompt with a filename: This file
Sometimes I heard people discussing about the start-up time for Java. It seems this
I sometimes end up having data in an array that starts far into the
I use a lot of local topic branches in git, and sometimes end up

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.