# FR: Support structured binding with JUCE types

**URL:** <https://forum.juce.com/t/fr-support-structured-binding-with-juce-types/52285>\
**Category:** Feature Requests\
**Created:** [July 22, 2022, 4:02pm UTC](https://forum.juce.com/t/fr-support-structured-binding-with-juce-types/52285 "2022-07-22T16:02:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [July 22, 2022, 4:02pm UTC](https://forum.juce.com/t/fr-support-structured-binding-with-juce-types/52285/1 "2022-07-22T16:02:40Z")

</div>

If I have a function like `juce::Range<float> getRange()` it would be nice to be able to do:

```auto
auto [start, end] = getRange();

```

---

<div class="post-metadata">

**Author:** ![eyalamir](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyalamir/32/2978_2.png) [@eyalamir](https://forum.juce.com/u/eyalamir)\
**Post date:** [July 22, 2022, 5:51pm UTC](https://forum.juce.com/t/fr-support-structured-binding-with-juce-types/52285/2 "2022-07-22T17:51:27Z")

</div>

I think all that’s required for that is to make the elements public, right?

I like it. But for the time being, you can also maybe use this workaround:

```auto
template <typename T>
struct TempRange
{
    TempRange(const juce::Range<T>& range)
        : start(range.getStart(), end(range.getEnd()))
    {
    }

    T start, end;
};

juce::Range<float> getJUCERange();
TempRange<float> getRange()
{
    return getJUCERange();
}

int main()
{
    auto[start, end] = getRange();
    return start;
}
```

---

<div class="post-metadata">

**Author:** ![PluginPenguin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/pluginpenguin/32/10203_2.png) [@PluginPenguin](https://forum.juce.com/u/PluginPenguin)\
**Post date:** [July 22, 2022, 7:04pm UTC](https://forum.juce.com/t/fr-support-structured-binding-with-juce-types/52285/3 "2022-07-22T19:04:22Z")

</div>

Adding structured binding support for arbitrary custom types works by supplying template specialisations for `std::tuple_size`, `std::tuple_element` and `std::get`. [This blog entry](https://blog.tartanllama.xyz/structured-bindings/) describes it in detail.

Since these are free functions, you can just implement them yourself in your code without needing to wait for JUCE to implement it.

Still I support this request, I think there are some types that could benefit from it. By the way, `dsp::ProcessorChain` already supports it, which is quite handy, I don‘t know if there are already further JUCE types with structured binding support?

---

<div class="post-metadata">

**Author:** ![nicolasdanet](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/nicolasdanet/32/56_2.png) [@nicolasdanet](https://forum.juce.com/u/nicolasdanet)\
**Post date:** [July 23, 2022, 4:58am UTC](https://forum.juce.com/t/fr-support-structured-binding-with-juce-types/52285/4 "2022-07-23T04:58:17Z")

</div>

See Also: \< [Code Style Request: More public members, pls - #65 by nicolasdanet](https://forum.juce.com/t/code-style-request-more-public-members-pls/50768/65) \>
