Skip to main content
  1. About
  2. Stack Internal
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

What does the [[carries_dependency]] attribute mean?

Can someone explain it in a language that mere mortals understand?

Answer*

Reminder: Answers generated by AI tools are not allowed due to Stack Overflow's artificial intelligence policy

Draft saved
Draft discarded

Required fields are marked with *

Cancel
13
  • 21
    This is a great answer. But... how would you go about coding the function to preserve the dependency? What would an improperly coded function look like and what would the consequences be?
    Omnifarious
    –  Omnifarious
    2011-06-20 13:20:02 +00:00
    Commented Jun 20, 2011 at 13:20
  • 2
    BTW, I got a pre-release copy of your book as a PDF. It is a fantastic book. I really wish you had carried on your 'person in a cubicle receiving phone calls' metaphor all the way through though. That was a great tool for understanding what was going on.
    Omnifarious
    –  Omnifarious
    2011-06-20 13:31:06 +00:00
    Commented Jun 20, 2011 at 13:31
  • 5
    From the POV of the source, all you need to do is use the [[carries_dependency]] attribute, and not call std::kill_dependency unless you mean it. The compiler will then ensure that it doesn't break the dependency chain in the generated code.
    Anthony Williams
    –  Anthony Williams
    2011-06-20 16:31:56 +00:00
    Commented Jun 20, 2011 at 16:31
  • 11
    @AnthonyWilliams: I'm with Omnifarious here: it sounds like you just have to plaster all the function declarations with [[carries_dependency]] and the compiler will magically generate faster code. I'd be interested in an example function where you cannot use [[carries_dependency]] or where you'd have to use std::kill_dpendency.
    Marc Mutz - mmutz
    –  Marc Mutz - mmutz
    2012-07-02 17:40:17 +00:00
    Commented Jul 2, 2012 at 17:40
  • 2
    @MarcMutz-mmutz "the compiler will magically generate faster code" Wrong. The compiler will generate equal, or less optimized (slower) code.
    curiousguy
    –  curiousguy
    2012-07-29 06:30:28 +00:00
    Commented Jul 29, 2012 at 6:30

lang-cpp
Morty Proxy This is a proxified and sanitized view of the page, visit original site.