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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:49:46+00:00 2026-06-17T06:49:46+00:00

I’m still evaluating if i should start using D for prototyping numerical code in

  • 0

I’m still evaluating if i should start using D for prototyping numerical code in physics.

One thing that stops me is I like boost, specifically fusion and mpl.

D is amazing for template meta-programming and i would think it can do mpl and fusion stuff but I would like to make sure.

Even if i’ll start using d, it would take me a while to get to the mpl level. So i’d like someone to share their experience.

(by mpl i mean using stl for templates and by fusion, i mean stl for tuples.)

a note on performance would be nice too, since it’s critical in physics simulations.

  • 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-17T06:49:47+00:00Added an answer on June 17, 2026 at 6:49 am

    In D, for the most part, meta-programming is just programming. There’s not really any need for a library like boost.mpl

    For example, consider the lengths you would have to go to in C++ to sort an array of numbers at compile time. In D, you just do the obvious thing: use std.algorithm.sort

    import std.algorithm;
    
    int[] sorted(int[] xs)
    {
        int[] ys = xs.dup;
        sort(ys);
        return ys;
    }
    
    pragma(msg, sorted([2, 1, 3]));
    

    This prints out [1, 2, 3] at compile time. Note: sort is not built into the language and has absolutely no special code for working at compile time.

    Here’s another example that builds a lookup table for Fibonacci sequence at compile time.

    int[] fibs(int n)
    {
        auto fib = recurrence!("a[n-1] + a[n-2]")(1, 1);
        int[] ret = new int[n];
        copy(fib.take(n), ret);
        return ret;
    }
    
    immutable int[] fibLUT = fibs(10).assumeUnique();
    

    Here, fibLUT is constructed entirely at compile time, again without any special compile time code needed.

    If you want to work with types, there are a few type meta functions in std.typetuple. For example:

    static assert(is(Filter!(isUnsigned, int, byte, ubyte, dstring, dchar, uint, ulong) ==
                  TypeTuple!(ubyte, uint, ulong)));
    

    That library, I believe, contains most of the functionality you can get from Fusion. Remember though, you really don’t need to use much of template meta-programming stuff in D as much as you do in C++, because most of the language is available at compile time anyway.

    I can’t really comment on performance because I don’t have vast experience with both. However, my instinct would be that D’s compile time execution is faster because you generally don’t need to instantiate numerous templates. Of course, C++ compilers are more mature, so I could be wrong here. The only way you’ll really find out is by trying it for your particular use case.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am using JSon response to parse title,date content and thumbnail images and place

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.