На главную Наши проекты:
Журнал   ·   Discuz!ML   ·   Wiki   ·   DRKB   ·   Помощь проекту
ПРАВИЛА FAQ Помощь Участники Календарь Избранное RSS
msm.ru
Модераторы: Qraizer, Hsilgos
Страницы: (77) « Первая ... 54 55 [56] 57 58 ...  76 77  ( Перейти к последнему сообщению )  
> Текущий Стандарт С++ и перспективы его развития
    Я там выше написал, что посмотрел в malloc.h как объявлены _alloca и alloca. Там написано, что
    ExpandedWrap disabled
      #define alloca(x) __builtin_alloca((x))
    то есть это реализуется встроенными средствами самого компилятора.
      А вот и свеженький драфт C++14.

      Добавлено
      Бинго! init-capture попала в стандарт!
      И auto-тип для аргументов лямбд тоже. :)
      Сообщение отредактировано: Flex Ferrum -
        Цитата
        The closure type for a non-generic lambda-expression has a public inline function call operator (13.5.4)
        whose parameters and return type are described by the lambda-expression’s parameter-declaration-clause
        and trailing-return-type respectively. For a generic lambda, the closure type has a public inline function call
        operator member template (14.5.2) whose template-parameter-list consists of one invented type templateparameter
        for each occurrence of auto in the lambda’s parameter-declaration-clause, in order of appearance.
        The invented type template-parameter is a parameter pack if the corresponding parameter-declaration declares
        a function parameter pack (8.3.5). The return type and function parameters of the function call
        operator template are derived from the lambda-expression’s trailing-return-type and parameter-declarationclause
        by replacing each occurrence of auto in the decl-specifiers of the parameter-declaration-clause with
        the name of the corresponding invented template-parameter.

        :victory: Generic-лямбды мало того, что могут принимать аргументы любых типов, так ещё и любое количество аргументов! Интересно, в каком gcc их реализуют? 4.9?

        Добавлено
        Туда же:
        Цитата
        An array of runtime bound shall only be used as the type of a local object with automatic storage duration.
        If the size of the array exceeds the size of the memory available for objects with automatic storage duration,
        the behavior is undefined.100 It is unspecified whether a global allocation function (3.7.4) is invoked to
        obtain storage for the array. If it is invoked, the corresponding global deallocation function is invoked to
        release the storage after the lifetime of the array has ended.101

        (8.3.4)
        ExpandedWrap disabled
          template <class T>
          class optional
          {
          public:
          typedef T value_type;
          // 20.6.4.1, constructors
          constexpr optional() noexcept;
          constexpr optional(nullopt_t) noexcept;
          optional(const optional&);
          optional(optional&&) noexcept(see below );
          constexpr optional(const T&);
          constexpr optional(T&&);
          template <class... Args> constexpr explicit optional(in_place_t, Args&&...);
          template <class U, class... Args>
          constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...);
          // 20.6.4.2, destructor
          ~optional();
          // 20.6.4.3, assignment
          optional& operator=(nullopt_t) noexcept;
          optional& operator=(const optional&);
          optional& operator=(optional&&) noexcept(see below );
          template <class U> optional& operator=(U&&);
          template <class... Args> void emplace(Args&&...);
          template <class U, class... Args> void emplace(initializer_list<U>, Args&&...);
          // 20.6.4.4, swap
          void swap(optional&) noexcept(see below );
          // 20.6.4.5, observers
          constexpr T const* operator->() const;
          T* operator->();
          constexpr T const& operator*() const;
          T& operator*();
          constexpr explicit operator bool() const noexcept;
          constexpr T const& value() const;
          T& value();
          template <class U> constexpr T value_or(U&&) const&;
          template <class U> T value_or(U&&) &&;
          private:
          bool init; // exposition only
          T* val; // exposition only
          };
          Цитата Flex Ferrum @
          Бинго! init-capture попала в стандарт!

          А можно вкратце, что это и какая с него практическая польза?
            Ну чё, скоро в std добавят функцию
            ExpandedWrap disabled
              template<typename ...Args1>
              template<typename ...Args2>
              std::tuple<Args1...> solve_current_problem(Args2...);
            и программировать станет скучно.
              Цитата B.V. @
              А можно вкратце, что это и какая с него практическая польза?

              Что-то вроде такого:
              ExpandedWrap disabled
                std::vector<int> nums(10);
                 
                std::generate(nums.begin(), nums.end(), [n = 0]() mutable {return n++;});


              Добавлено
              Цитата Qraizer @
              и программировать станет скучно.

              Ой, не знаю... Ой, не уверен. :D
                Цитата Qraizer @
                Ну чё, скоро в std добавят функцию
                ExpandedWrap disabled
                  template<typename ...Args1>
                  template<typename ...Args2>
                  std::tuple<Args1...> solve_current_problem(Args2...);
                и программировать станет скучно.

                ну, нечто подобное уже сейчас можно использовать:
                ExpandedWrap disabled
                  #include <iostream>
                  #include <tuple>
                  #include <typeinfo>
                   
                  template<typename... Args1, typename... Args2>
                  std::tuple<Args1...> func(Args2&&... args) {
                      return std::make_tuple(args...);
                  }
                   
                  int main() {
                      auto r = func<char, double, int>(3, 3.14, 'c');
                      
                      std::cout << "0:" << typeid(std::get<0>(r)).name() << std::endl;
                      std::cout << "1:" << typeid(std::get<1>(r)).name() << std::endl;
                      std::cout << "2:" << typeid(std::get<2>(r)).name() << std::endl;
                  }

                вывод:
                Цитата

                0:c
                1:d
                2:i
                  Цитата niXman @
                  ну, нечто подобное уже сейчас можно использовать:

                  Ты явно не понял прикола. :)

                  ЗЫ: А когда LWS перейдёт из режима R/O в полнофункциональный?
                    Цитата Flex Ferrum @
                    Ты явно не понял прикола.

                    ах да, я на название функции не обратил внимания =)
                    Цитата Flex Ferrum @
                    когда LWS перейдёт из режима R/O в полнофункциональный?

                    надеюсь, к концу следующей недели.
                      Во, я всегда говорю - имя функции должно быть не больше 2-3 символов, всё равно никто не читает.
                        А кто-нибудь пробовал прикручивать новый компилятор, например, от Vs2012 к старой (например, Vs2010) студии ? Чтобы она совмещалась с последней версией стандарта. Уж очень мне нравятся все эти сахарные обновляшечки. Без initializer_list вот очень туго живется.
                          Я пробовал прикручивать компилятор от 2010-ой к 2008-ой. Вроде бы получалось. Делал посредством полной замены содержимого директории с компилятором (и директорий с заголовочными файлами и библиотеками). Наверное, и в твоем случае это может получиться.
                            Flex Ferrum

                            Нет, не получается ...

                            Цитата
                            1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(153,5): error MSB6006: "CL.exe" завершилась с кодом -1073741515.


                            Видимо, разница слишком велика (vs2012 у меня вылетает, как я говорил).
                              Судя по, в новой студии наконец-то появятся variadic'и.
                                Цитата MyNameIsIgor @
                                Судя по, в новой студии наконец-то появятся variadic'и.
                                Ноябрьский CTP компилятор?
                                1 пользователей читают эту тему (1 гостей и 0 скрытых пользователей)
                                0 пользователей:
                                Страницы: (77) « Первая ... 54 55 [56] 57 58 ...  76 77


                                Рейтинг@Mail.ru
                                [ Script execution time: 0,1002 ]   [ 15 queries used ]   [ Generated: 9.06.24, 09:31 GMT ]