HISE Logo Forum
    • Categories
    • Register
    • Login

    SNEX span unsafe index?

    Scheduled Pinned Locked Moved Unsolved Scripting
    1 Posts 1 Posters 61 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ustkU
      ustk
      last edited by ustk

      Whatever I do, I get an unsafe access.
      In a previous SNEX code, I used a normalised index for a safe LUT (span) access with no issues.
      But here I am struggling with not a shred of explanation...

      	span<Params, NB> models =
      	{
      		{0.0f, 0.0f, 0.0f},
      		{0.0f, 0.0f, 0.0f}
      	};
      
      	using IndexType = index::clamped<NB, true>;
      	
      	Params currentModel;
      
      	template <int P> void setParameter(double v)
      	{
      		if (P == Parameters::Model)
      		{
      			IndexType idx((int)v);
      			currentModel = models[idx]; // unsafe access
      		}
      	}
      

      Can't help pressing F5 in the forum...

      1 Reply Last reply Reply Quote 0
      • ustkU ustk marked this topic as a question on
      • First post
        Last post

      20

      Online

      1.8k

      Users

      12.1k

      Topics

      105.1k

      Posts