Implement constructor manually

1

I have to modify the following program in order to compile it with GCC 4.9.2. The problem is because GCC can not implement some noexcept move constructors like "= default".

I have to implement the constructor manually (on foot) and I do not know how.

Line 7 is the one that is causing problems and is the one that should be modified:

'TabStats::TabStats(TabStats&& other) noexcept = default;'

As a condition, the noexcept specifier should not be removed.

Source code :

#include "browser/resource_coordinator/tab_stats.h"
#include "build/build_config.h"

namespace resource_coordinator {
TabStats::TabStats() = default;
TabStats::TabStats(const TabStats& other) = default;
TabStats::TabStats(TabStats&& other) noexcept = default;
TabStats::~TabStats() {}
TabStats& TabStats::operator=(const TabStats& other) = default;
}  // namespace resource_coordinator

I also include tab_stats.h here below:

#ifndef CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_STATS_H_
#define CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_STATS_H_
#include <stdint.h>
#include <vector>
#include "base/process/process.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "build/build_config.h"

namespace content {
class RenderProcessHost;
}  // namespace content

namespace resource_coordinator {

struct TabStats {
  TabStats();
  TabStats(const TabStats& other);
  TabStats(TabStats&& other) noexcept;
  ~TabStats();

  TabStats& operator=(const TabStats& other);

  bool is_app = false;            // Browser window is an app.
  bool is_internal_page = false;  // Internal page, such as NTP or Settings.
  // Playing audio, accessing cam/mic or mirroring display.
  bool is_media = false;
  bool is_pinned = false;
  bool is_in_visible_window = false;
  bool is_in_active_window = false;
  // Whether this is the active tab in a browser window.
  bool is_active = false;
  bool is_discarded = false;
  // User has entered text in a form.
  bool has_form_entry = false;
  int discard_count = 0;
  bool has_beforeunload_handler = false;
  base::TimeTicks last_active;
  base::TimeTicks last_hidden;
  content::RenderProcessHost* render_process_host = nullptr;
  base::ProcessHandle renderer_handle = 0;
  int child_process_host_id = 0;
  base::string16 title;
#if defined(OS_CHROMEOS)
  int oom_score = 0;
#endif
  int64_t tab_contents_id = 0;  // Unique ID per WebContents.
  bool is_auto_discardable = true;
};

typedef std::vector<TabStats> TabStatsList;

}  // namespace resource_coordinator

#endif
    
asked by bari 01.11.2017 в 06:46
source

1 answer

0

GCC 4.9.2 yes supports those C ++ 11 features. What happens is that, by default, the standard in question is not enabled. Instead of C ++ 11 the compiler handles the code under the C ++ 03 standard, which does not support these features.

To enable them compile with the flag -std=c++11 (respect the lowercase)

    
answered by 01.11.2017 в 23:22