1// Copyright (C) 2011 John Maddock 2// Use, modification and distribution are subject to the 3// Boost Software License, Version 1.0. (See accompanying file 4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6// See http://www.boost.org/libs/config for most recent version. 7 8// MACRO: BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX 9// TITLE: C++0x unified initialization syntax unavailable 10// DESCRIPTION: The compiler does not support C++0x unified initialization syntax: see http://en.wikipedia.org/wiki/C%2B%2B0x#Uniform_initialization 11 12#include <string> 13 14namespace boost_no_cxx11_unified_initialization_syntax { 15 16struct BasicStruct 17{ 18 int x; 19 double y; 20}; 21 22struct AltStruct 23{ 24public: 25 AltStruct(int x, double y) : x_{x}, y_{y} {} 26 int X() const { return x_; } 27 double Y() const { return y_; } 28private: 29 int x_; 30 double y_; 31}; 32 33struct IdString 34{ 35 std::string name; 36 int identifier; 37 bool operator == (const IdString& other) 38 { 39 return identifier == other.identifier && name == other.name; 40 } 41}; 42 43IdString get_string() 44{ 45 return {"SomeName", 4}; //Note the lack of explicit type. 46} 47 48int test() 49{ 50 BasicStruct var1{5, 3.2}; 51 AltStruct var2{2, 4.3}; 52 (void) var1; 53 (void) var2; 54 55 IdString id{"SomeName", 4}; 56 return id == get_string() ? 0 : 1; 57} 58 59} 60