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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:06:03+00:00 2026-05-25T16:06:03+00:00

I have a boring function to run, I want to loop through it to

  • 0

I have a boring function to run, I want to loop through it to save this time (I have all the data to), but it requires types. Is there a way to make an array of types, or have some comple-time thing to do this? (If it helps, I have 3 types and want to run the method with all types against all types).

fprintf(stdout, "Testing UTF-32...\n");
testUTF<uint32_t, uint32_t>(&testEncs[0], &testEncs[0]);
testUTF<uint32_t, uint16_t>(&testEncs[0], &testEncs[1]);
testUTF<uint32_t, uint8_t> (&testEncs[0], &testEncs[2]);

fprintf(stdout, "Testing UTF-16...\n");
testUTF<uint16_t, uint32_t>(&testEncs[1], &testEncs[0]);
testUTF<uint16_t, uint16_t>(&testEncs[1], &testEncs[1]);
testUTF<uint16_t, uint8_t> (&testEncs[1], &testEncs[2]);

fprintf(stdout, "Testing UTF-8...\n");
testUTF<uint8_t,  uint32_t>(&testEncs[2], &testEncs[0]);
testUTF<uint8_t,  uint16_t>(&testEncs[2], &testEncs[1]);
testUTF<uint8_t,  uint8_t> (&testEncs[2], &testEncs[2]);
  • 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-25T16:06:04+00:00Added an answer on May 25, 2026 at 4:06 pm
    template <int I> struct UType;
    template <> struct UType<0> { typedef uint32_t Type; };
    template <> struct UType<1> { typedef uint16_t Type; };
    template <> struct UType<2> { typedef uint8_t Type; };
    static const int n_types = 3;
    
    template <int A,int B>
    struct Test {
      typedef typename UType<A>::Type AType;
      typedef typename UType<B>::Type BType;
      static void test()
      {
        testUTF<AType,BType>(&testEncs[A],&testEncs[B]);
        Test<A,B+1>::test();
      }
    };
    
    template <int A>
    struct Test<A,n_types> {
      static void test() { Test<A+1,0>::test(); }
    };
    
    template <>
    struct Test<n_types,0> {
      static void test() { }
    };
    
    void testAll()
    {
      Test<0,0>::test();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this for loop in jquery $(document).ready(function() { for(i=0; i<counter; i++) { dataCounter
Problem: I have a function that gets passed data and a size. But I
The Situation (Ignore this it is boring): I have reports that I created using
I have a feeling I am completely borking this MySQL query but I'll ask
I have the following code, which compiles but doesn't bring back any data. Here
I have an application which opens multiple JIFs, But I only want to create
Say I have a jquery function within JavaScript and I have this code so
I seem to have a problem, I have a growing business to run but
I have gone through the N2 CMS documentation at length and can see no
I am curious and hopefully someone can shed somelight on this - but why

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.