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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:09:01+00:00 2026-06-14T17:09:01+00:00

The following didactic example illustrates my problem : #include <iostream> #include <cmath> template<class Function,

  • 0

The following didactic example illustrates my problem :

#include <iostream>
#include <cmath>

template<class Function, class... Args>
double apply(Function f, Args... args)
{
    return f(args...);
}

template<class Function, class... Args>
double applybis(Function f, Args... args)
{
    return f(std::sin(args...));// <- How to apply a function to 
                                // each variadic parameter and 
                                // return a modified variadic list ?
}

int main(int argc, char* argv[])
{
    std::cout<<apply(static_cast<double(*)(double)>(std::sin), 3.)<<std::endl;
    return 0;
}

How to “transform” a variadic list by applying a function to each component and return a modified variadic list ?
(Is there a way to write the applybis function without modifying its current signature ?)

  • 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-14T17:09:02+00:00Added an answer on June 14, 2026 at 5:09 pm

    Here you go:

    return f(std::sin(args)...);
    

    That is, ... should come after (args).

    It expands/unpacks to this form:

    return f( std::sin(arg0), std::sin(arg1), ......, std::sin(argN) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following is my javascript code. The problem is when I call the send() function
Following is the repetivite html structure that i have in my template: <div class=mystyle
Following code worked fine abstract class FunctionRunnable<V> implements Runnable { protected abstract V calculate();
Following example code from the libpcap documentation yields the following code which should report
following problem: I have a simple paragraph with a lot of text where I
Following is my code: <table border=0 align=center cellpadding=0 cellspacing=0 class=grid_table> <tr class=grid_caption><td class=grid_caption>Customer Name</td></tr>
I have been trying to implement my own linked list class for didactic purposes.
Following code is an example of text placed into a textarea from a database.
Following code is giving compilation error in visual studio 2009. #include <iterator> #include <vector>
Following this example on another thread, I am able to tweet either the URL:

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.