Skip to content

Commit

Permalink
added custom initializer_list.h class for avr devices on arduino
Browse files Browse the repository at this point in the history
  • Loading branch information
robosam2003 committed Mar 3, 2023
1 parent ffb78cd commit 7668326
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
#ifndef VECTOR_LIBRARY_H
#define VECTOR_LIBRARY_H



#include <iostream>
#include <cmath>
// External
#include "initializer_list.h" // for avr devices /:)
#include <math.h>

template<typename T, unsigned int s>
class Vector {
Expand Down
108 changes: 108 additions & 0 deletions initializer_list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// std::initializer_list support -*- C++ -*-

// Copyright (C) 2008-2014 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// GCC is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.

/** @file initializer_list
* This is a Standard C++ Library header.
*/

#ifndef _INITIALIZER_LIST
#define _INITIALIZER_LIST

#pragma GCC system_header

#if __cplusplus < 201103L
//# include <bits/c++0x_warning.h>
#else // C++0x

#pragma GCC visibility push(default)

#include <stddef.h>
//#include <bits/c++config.h>

namespace std
{
/// initializer_list
template<class E>
class initializer_list
{
public:
typedef E value_type;
typedef const E& reference;
typedef const E& const_reference;
typedef size_t size_type;
typedef const E* iterator;
typedef const E* const_iterator;

private:
iterator _M_array;
size_type _M_len;

// The compiler can call a private constructor.
constexpr initializer_list(const_iterator __a, size_type __l)
: _M_array(__a), _M_len(__l) { }

public:
constexpr initializer_list() noexcept
: _M_array(0), _M_len(0) { }

// Number of elements.
constexpr size_type
size() const noexcept { return _M_len; }

// First element.
constexpr const_iterator
begin() const noexcept { return _M_array; }

// One past the last element.
constexpr const_iterator
end() const noexcept { return begin() + size(); }
};

/**
* @brief Return an iterator pointing to the first element of
* the initializer_list.
* @param __ils Initializer list.
*/
template<class _Tp>
constexpr const _Tp*
begin(initializer_list<_Tp> __ils) noexcept
{ return __ils.begin(); }

/**
* @brief Return an iterator pointing to one past the last element
* of the initializer_list.
* @param __ils Initializer list.
*/
template<class _Tp>
constexpr const _Tp*
end(initializer_list<_Tp> __ils) noexcept
{ return __ils.end(); }
}

#pragma GCC visibility pop

#endif // C++11

#endif // _INITIALIZER_LIST

0 comments on commit 7668326

Please sign in to comment.